import java.util.Scanner; public class GCD { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x, y; x = input.nextInt(); y = input.nextInt(); int k, min, GCD; GCD = 1; // Best GCD so far min = (x < y) ? x : y; for ( k = 2; k <= min; k++ ) { if ( (x%k == 0) && (y%k == 0) ) GCD = k; // We found a better GCD } System.out.println(GCD); } }