import java.util.Scanner;

class MathUtil {
	public static long gcd(long x, long y) {
		if(x == 0) return y;
		if(y == 0) return x;
		if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		}
	}
}

class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long x = in.nextInt();
		long y = in.nextInt();
		System.out.println(MathUtil.gcd(x, y));
	}
} import java.util.Scanner; Scanner java.util class MathUtil {
	public static long gcd(long x, long y) {
		if(x == 0) return y;
		if(y == 0) return x;
		if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		}
	}
} MathUtil public static long gcd(long x, long y) {
		if(x == 0) return y;
		if(y == 0) return x;
		if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		}
	} gcd {
		if(x == 0) return y;
		if(y == 0) return x;
		if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		}
	} if(x == 0) return y; x == 0 x 0 return y; y if(y == 0) return x; y == 0 y 0 return x; x if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		} x >= y x y {
			return gcd(y, x % y);
		} return gcd(y, x % y); gcd(y, x % y) gcd y x % y x y {
			return gcd(x, y % x);
		} return gcd(x, y % x); gcd(x, y % x) gcd x y % x y x long x x long y y class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long x = in.nextInt();
		long y = in.nextInt();
		System.out.println(MathUtil.gcd(x, y));
	}
} Main public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long x = in.nextInt();
		long y = in.nextInt();
		System.out.println(MathUtil.gcd(x, y));
	} main {
		Scanner in = new Scanner(System.in);
		long x = in.nextInt();
		long y = in.nextInt();
		System.out.println(MathUtil.gcd(x, y));
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) long x = in.nextInt(); x in.nextInt() in.nextInt in long y = in.nextInt(); y in.nextInt() in.nextInt in System.out.println(MathUtil.gcd(x, y)) System.out.println System.out System System.out MathUtil.gcd(x, y) MathUtil.gcd MathUtil x y String args[] args
import java.util.Scanner;

class MathUtil {
	public static long gcd(long x, long y) {
		if(x == 0) return y;
		if(y == 0) return x;
		if(x >= y) {
			return gcd(y, x % y);
		} else {
			return gcd(x, y % x);
		}
	}
}

class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		long x = in.nextInt();
		long y = in.nextInt();
		System.out.println(MathUtil.gcd(x, y));
	}
}