import java.util.Scanner;

public class Main {

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

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

		System.out.println(gcd(x, y));
		sc.close();

	}
	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	}

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

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

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

		System.out.println(gcd(x, y));
		sc.close();

	}
	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	}

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

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

		System.out.println(gcd(x, y));
		sc.close();

	} main {

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

		System.out.println(gcd(x, y));
		sc.close();

	} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y sc.close() sc.close sc String[] args args private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	} gcd {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	} int x_tmp = 0; x_tmp 0 do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0); y > 0 y 0 {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		} x_tmp = x x_tmp x x = y x y y = x_tmp % y y x_tmp % y x_tmp y return x; x int x x int y y public class Main {

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

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

		System.out.println(gcd(x, y));
		sc.close();

	}
	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	}

} public class Main {

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

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

		System.out.println(gcd(x, y));
		sc.close();

	}
	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	}

} Main
import java.util.Scanner;

public class Main {

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

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

		System.out.println(gcd(x, y));
		sc.close();

	}
	private static int gcd(int x, int y) {
		int x_tmp = 0;

		do {
			x_tmp = x;

			x = y;
			y = x_tmp % y;

		}while(y > 0);

		return x;
	}

}
