import java.io.File;
import java.util.Scanner;

public class Main {
	public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	}
} import java.io.File; File java.io import java.util.Scanner; Scanner java.util public class Main {
	public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	}
} Main public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	} gcd {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	} if (x == 0)
			return y;
		else
			return gcd(y % x, x); x == 0 x 0 return y; y return gcd(y % x, x); gcd(y % x, x) gcd y % x y x x int x x int y y public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	} main {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt() x sc.nextInt() sc.nextInt sc y = sc.nextInt(); y sc.nextInt() sc.nextInt sc if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x)); x <= y x y System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y System.out.println(gcd(y, x)) System.out.println System.out System System.out gcd(y, x) gcd y x String[] args args public class Main {
	public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	}
} public class Main {
	public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	}
} Main
import java.io.File;
import java.util.Scanner;

public class Main {
	public static int gcd(int x, int y) {
		// x <= y?????????
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// Scanner sc = new Scanner(new File("test_1.txt"));
		// Scanner sc = new Scanner(new File("test_2.txt"));
		int x = sc.nextInt(), y = sc.nextInt();
		if (x <= y)
			System.out.println(gcd(x, y));
		else
			System.out.println(gcd(y, x));
	}
}