public static void main(String[] args) throws Exception { BufferedReader buf = new BufferedReader(new InputStreamReader(System.in)); int a = Integer.parseInt(buf.readLine()); int b = Integer.parseInt(buf.readLine()); if (a <= 0) throw new Exception(); buf.close(); System.out.println(NodFinder(a,b)); }// end psvm public static int NodFinder(int a, int b){ int min = Math.min(a,b); int diff = Math.abs(a-b); int temp; while(true){ if (min == diff) return min; temp = min; min = Math.min(min,diff); diff = Math.abs(diff-temp); } }