import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int x = stdIn.nextInt();
		int y = stdIn.nextInt();


		int answer = x % y;

		while (answer != 0) {
			x = y;
			y = answer;
			answer = x % y;
		}

		System.out.println(y);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int x = stdIn.nextInt();
		int y = stdIn.nextInt();


		int answer = x % y;

		while (answer != 0) {
			x = y;
			y = answer;
			answer = x % y;
		}

		System.out.println(y);
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int x = stdIn.nextInt();
		int y = stdIn.nextInt();


		int answer = x % y;

		while (answer != 0) {
			x = y;
			y = answer;
			answer = x % y;
		}

		System.out.println(y);
	} main {
		Scanner stdIn = new Scanner(System.in);

		int x = stdIn.nextInt();
		int y = stdIn.nextInt();


		int answer = x % y;

		while (answer != 0) {
			x = y;
			y = answer;
			answer = x % y;
		}

		System.out.println(y);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn int y = stdIn.nextInt(); y stdIn.nextInt() stdIn.nextInt stdIn int answer = x % y; answer x % y x y while (answer != 0) {
			x = y;
			y = answer;
			answer = x % y;
		} answer != 0 answer 0 {
			x = y;
			y = answer;
			answer = x % y;
		} x = y x y y = answer y answer answer = x % y answer x % y x y System.out.println(y) System.out.println System.out System System.out y String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int x = stdIn.nextInt();
		int y = stdIn.nextInt();


		int answer = x % y;

		while (answer != 0) {
			x = y;
			y = answer;
			answer = x % y;
		}

		System.out.println(y);
	}
}