import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	} run {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		} y > x y x {
			int swap = x;
			x = y;
			y = swap;
		} int swap = x; swap x x = y x y y = swap y swap while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		} x > y x y {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		} int n = x % y; n x % y x y if (n == 0) break; n == 0 n 0 break; x = y x y y = n y n System.out.println(y) System.out.println System.out System System.out y 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 scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		if (y > x) {
			int swap = x;
			x = y;
			y = swap;
		}
		while (x > y) {
			int n = x % y;
			if (n == 0) break;
			x = y;
			y = n;
		}
		System.out.println(y);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

