import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(euclid(Math.max(a, b), Math.min(a, b)));
	}
	public static int euclid(int a, int b){
		int c;
		while((c = a % b) != 0){
			a = b;
			b = c;
		}
		return b;
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(euclid(Math.max(a, b), Math.min(a, b)));
	}
	public static int euclid(int a, int b){
		int c;
		while((c = a % b) != 0){
			a = b;
			b = c;
		}
		return b;
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(euclid(Math.max(a, b), Math.min(a, b)));
	} main {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(euclid(Math.max(a, b), Math.min(a, b)));
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan System.out.println(euclid(Math.max(a, b), Math.min(a, b))) System.out.println System.out System System.out euclid(Math.max(a, b), Math.min(a, b)) euclid Math.max(a, b) Math.max Math a b Math.min(a, b) Math.min Math a b String[] args args public static int euclid(int a, int b){
		int c;
		while((c = a % b) != 0){
			a = b;
			b = c;
		}
		return b;
	} euclid {
		int c;
		while((c = a % b) != 0){
			a = b;
			b = c;
		}
		return b;
	} int c; c while((c = a % b) != 0){
			a = b;
			b = c;
		} (c = a % b) != 0 (c = a % b) c a % b a b 0 {
			a = b;
			b = c;
		} a = b a b b = c b c return b; b int a a int b b
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(euclid(Math.max(a, b), Math.min(a, b)));
	}
	public static int euclid(int a, int b){
		int c;
		while((c = a % b) != 0){
			a = b;
			b = c;
		}
		return b;
	}
}