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();

		System.out.println(calc(x, y));
	}

	private static int calc(int x, int y) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return 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();

		System.out.println(calc(x, y));
	}

	private static int calc(int x, int y) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return x;
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(calc(x, y));
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(calc(x, y));
	} 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 System.out.println(calc(x, y)) System.out.println System.out System System.out calc(x, y) calc x y String args[] args private static int calc(int x, int y) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return x;
	} calc {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return x;
	} if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		} x < y x y {
			int tmp = x;
			x = y;
			y = tmp;
		} int tmp = x; tmp x x = y x y y = tmp y tmp while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		} y > 0 y 0 {
			int r = x % y;
			x = y;
			y = r;
		} int r = x % y; r x % y x y x = y x y y = r y r return x; x int x x int y y public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(calc(x, y));
	}

	private static int calc(int x, int y) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return x;
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(calc(x, y));
	}

	private static int calc(int x, int y) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return 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();

		System.out.println(calc(x, y));
	}

	private static int calc(int x, int y) {
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		while (y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}

		return x;
	}
}