import java.util.Scanner;


public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	}
	
	int gcd(int x, int y) {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	}
	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	}
	
	int gcd(int x, int y) {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	} run {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	} 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 System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y int gcd(int x, int y) {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	} gcd {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	} int rem; rem int largenum; largenum if (x == 1 || y == 1) return 1; x == 1 || y == 1 x == 1 x 1 y == 1 y 1 return 1; 1 if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x; x > y x y {
			rem = x % y;
			largenum = x;
		} rem = x % y rem x % y x y largenum = x largenum x if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x; y > x y x {
			rem = y % x;
			largenum = x;
		} rem = y % x rem y % x y x largenum = x largenum x return x; x for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i; int i = rem - 1; int i = rem - 1; i rem - 1 rem 1 i > 0 i 0 i-- i-- i if (rem % i == 0 && largenum % i == 0) return i; if (rem % i == 0 && largenum % i == 0) return i; rem % i == 0 && largenum % i == 0 rem % i == 0 rem % i rem i 0 largenum % i == 0 largenum % i largenum i 0 return i; i return rem; rem int x x int y y public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	}
	
	int gcd(int x, int y) {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	}
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	}
	
	int gcd(int x, int y) {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;


public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		System.out.println(gcd(x, y));
	}
	
	int gcd(int x, int y) {
		int rem;
		int largenum;
		if (x == 1 || y == 1) return 1;
		if (x > y) {
			rem = x % y;
			largenum = x;
		} else if (y > x) {
			rem = y % x;
			largenum = x;
		} else return x;
		for (int i = rem - 1; i > 0; i--)
			if (rem % i == 0 && largenum % i == 0) return i;
		return rem;
	}
	public static void main(String[] args) {
		new Main().run();
	}
}