import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	} main {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		} true {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		} if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			} x < y x y {
				int tmp1 = x;
				x = y;
				y = tmp1;
			} int tmp1 = x; tmp1 x x = y x y y = tmp1 y tmp1 int tmp2 = y; tmp2 y y = x % y y x % y x y x = tmp2 x tmp2 if (y == 0)
				break; y == 0 y 0 break; System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		while (true) {
			if (x < y) {
				int tmp1 = x;
				x = y;
				y = tmp1;
			}
			int tmp2 = y;
			y = x % y;
			x = tmp2;
			if (y == 0)
				break;
		}
		System.out.println(x);

	}

}
