import java.util.Scanner;

class Main {

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

		int x = scan.nextInt();
		int y = scan.nextInt();
		int d;
		int e;
		if (x >= y) {
			d = x % y;
			e = y;
		} else {
			d = y % x;
			e = x;
		}
		if (d == 0) {
			System.out.println(e);
		} else {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();

	}

} import java.util.Scanner; Scanner java.util class Main {

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

		int x = scan.nextInt();
		int y = scan.nextInt();
		int d;
		int e;
		if (x >= y) {
			d = x % y;
			e = y;
		} else {
			d = y % x;
			e = x;
		}
		if (d == 0) {
			System.out.println(e);
		} else {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();

	}

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

		int x = scan.nextInt();
		int y = scan.nextInt();
		int d;
		int e;
		if (x >= y) {
			d = x % y;
			e = y;
		} else {
			d = y % x;
			e = x;
		}
		if (d == 0) {
			System.out.println(e);
		} else {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();

	} main {
		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int y = scan.nextInt();
		int d;
		int e;
		if (x >= y) {
			d = x % y;
			e = y;
		} else {
			d = y % x;
			e = x;
		}
		if (d == 0) {
			System.out.println(e);
		} else {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();

	} 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 int d; d int e; e if (x >= y) {
			d = x % y;
			e = y;
		} else {
			d = y % x;
			e = x;
		} x >= y x y {
			d = x % y;
			e = y;
		} d = x % y d x % y x y e = y e y {
			d = y % x;
			e = x;
		} d = y % x d y % x y x e = x e x if (d == 0) {
			System.out.println(e);
		} else {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		} d == 0 d 0 {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		} for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			} int i = d; int i = d; i d d > 0 d 0 i-- i-- i {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			} {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			} if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				} d % i == 0 && e % i == 0 d % i == 0 d % i d i 0 e % i == 0 e % i e i 0 {
					System.out.println(i);
					break;
				} System.out.println(i) System.out.println System.out System System.out i break; scan.close() scan.close scan String args[] args
import java.util.Scanner;

class Main {

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

		int x = scan.nextInt();
		int y = scan.nextInt();
		int d;
		int e;
		if (x >= y) {
			d = x % y;
			e = y;
		} else {
			d = y % x;
			e = x;
		}
		if (d == 0) {
			System.out.println(e);
		} else {
			for (int i = d; d > 0; i--) {
				if (d % i == 0 && e % i == 0) {
					System.out.println(i);
					break;
				}
			}
		}
		scan.close();

	}

}
