import java.util.Scanner;

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

class Main {
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		
		System.out.println(koya(Math.max(x, y),Math.min(x, y)));
	}
	
	public static int koya(int a,int b){
		
		if(b == 0){
			return a;
		}else{
			return koya(b,a%b);
		}
	}
}
