package com.codegym.task.task14.task1420; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.*; public class Solution { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int a = Integer.parseInt(br.readLine()); int b = Integer.parseInt(br.readLine()); if (a < 0 || b < 0 ) { throw new NumberFormatException(); } System.out.println(gcd(a, b)); } public static int gcd(int a, int b){ int R; while((a % b) > 0){ R = a % b; a = b; b = R; } return b; } }