import java.util.Scanner;

public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int gcd = 0;
		if (x == y) {
			gcd = x;
		} else {
			gcd = calculation(x, y, gcd);
		}
		System.out.println(gcd);
		sc.close();
	}

	public static int calculation(int x, int y, int gcd) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		x %= y;
		for (int i = x; true; i--) {
			if (x % i == 0 && y % i == 0) {
				gcd = i;
				break;
			}
		}
		return gcd;
	}
}


/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz