import java.util.Scanner;

public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	}

	public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	}

	public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	}
} Main public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	} 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 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 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[] atgs atgs public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	} gcd {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	} int v = a % b; v a % b a b if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		} v == 0 v 0 {
			return b;
		} return b; b {
			return gcd(b, v);
		} return gcd(b, v); gcd(b, v) gcd b v int a a int b b public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	}

	public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	}
} public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	}

	public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] atgs) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		System.out.println(gcd(x, y));
		sc.close();
	}

	public static int gcd(int a, int b) {
		int v = a % b;
		if (v == 0) {
			return b;
		} else {
			return gcd(b, v);
		}
	}
}

