import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	} main {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	} gcd {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	} if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		} x % y == 0 x % y x y 0 {
			return y;
		} return y; y {
			return gcd(y, x % y);
		} return gcd(y, x % y); gcd(y, x % y) gcd y x % y x y int x x int y y public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	}
}
