import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	}
	int gcd(int a, int b) {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	}
	int gcd(int a, int b) {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int ans = gcd(a, b); ans gcd(a, b) gcd a b System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc int gcd(int a, int b) {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	} gcd {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	} if(a < b) {
			int c = a;
			a = b;
			b = c;
		} a < b a b {
			int c = a;
			a = b;
			b = c;
		} int c = a; c a a = b a b b = c b c if(b == 0) return a;
		else return gcd(b, a%b); b == 0 b 0 return a; a return gcd(b, a%b); gcd(b, a%b) gcd b a%b a b int a a int b b void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	} debug {
		System.out.println(Arrays.deepToString(o));
	} System.out.println(Arrays.deepToString(o)) System.out.println System.out System System.out Arrays.deepToString(o) Arrays.deepToString Arrays o Object... o o public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	}
	int gcd(int a, int b) {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	}
	int gcd(int a, int b) {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = gcd(a, b);
		System.out.println(ans);
		sc.close();
	}
	int gcd(int a, int b) {
		if(a < b) {
			int c = a;
			a = b;
			b = c;
		}
		if(b == 0) return a;
		else return gcd(b, a%b);
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
