import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long y = scan.nextLong();
		scan.close();
		long smaller = Math.min(x, y);
		long bigger = Math.max(x, y);
		System.out.println(GreatestCommonDivisor(bigger, smaller));
	}

	static long GreatestCommonDivisor(long x, long y){
		long mod = Math.floorMod(x, y);
		if(mod == 0){
			return y;
		}else{
			x = Math.max(y, mod);
			y = Math.min(y, mod);
			return GreatestCommonDivisor(x, y);
		}
	}
}
/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