import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	} main {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int x = Math.max(a, b); x Math.max(a, b) Math.max Math a b int y = Math.min(a, b); y Math.min(a, b) Math.min Math a b for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		} int mod = x % y; int mod = x % y; mod x % y x y mod != 0 mod 0 x = y, y = mod, mod = x % y x = y x y y = mod y mod mod = x % y mod x % y x y {
			
		} {
			
		} System.out.println(y) System.out.println System.out System System.out y sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int x = Math.max(a, b);
		int y = Math.min(a, b);
		
		for (int mod = x % y; mod != 0; x = y, y = mod, mod = x % y) {
			
		}
		
    	System.out.println(y);
    	
        sc.close();
	}
}