
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		
		int num01 = scanner.nextInt();
		int num02 = scanner.nextInt();
		int min = Math.min(num01, num02);
		int max = Math.max(num01, num02);
		int gcd = 1;// ?????§??¬?´???°???????´????????????°
		int surplus = 1;
		
		while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		}
		System.out.println(max);// ?????§??¬?´???°?????????
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) throws Exception {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		
		int num01 = scanner.nextInt();
		int num02 = scanner.nextInt();
		int min = Math.min(num01, num02);
		int max = Math.max(num01, num02);
		int gcd = 1;// ?????§??¬?´???°???????´????????????°
		int surplus = 1;
		
		while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		}
		System.out.println(max);// ?????§??¬?´???°?????????
	}
} Main public static void main(String[] args) throws Exception {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		
		int num01 = scanner.nextInt();
		int num02 = scanner.nextInt();
		int min = Math.min(num01, num02);
		int max = Math.max(num01, num02);
		int gcd = 1;// ?????§??¬?´???°???????´????????????°
		int surplus = 1;
		
		while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		}
		System.out.println(max);// ?????§??¬?´???°?????????
	} main {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		
		int num01 = scanner.nextInt();
		int num02 = scanner.nextInt();
		int min = Math.min(num01, num02);
		int max = Math.max(num01, num02);
		int gcd = 1;// ?????§??¬?´???°???????´????????????°
		int surplus = 1;
		
		while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		}
		System.out.println(max);// ?????§??¬?´???°?????????
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int num01 = scanner.nextInt(); num01 scanner.nextInt() scanner.nextInt scanner int num02 = scanner.nextInt(); num02 scanner.nextInt() scanner.nextInt scanner int min = Math.min(num01, num02); min Math.min(num01, num02) Math.min Math num01 num02 int max = Math.max(num01, num02); max Math.max(num01, num02) Math.max Math num01 num02 int gcd = 1; gcd 1 int surplus = 1; surplus 1 while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		} true {
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		} surplus = max % min surplus max % min max min max = min max min min = surplus min surplus if(surplus == 0){
				break;
			} surplus == 0 surplus 0 {
				break;
			} break; System.out.println(max) System.out.println System.out System System.out max String[] args args

import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		
		int num01 = scanner.nextInt();
		int num02 = scanner.nextInt();
		int min = Math.min(num01, num02);
		int max = Math.max(num01, num02);
		int gcd = 1;// ?????§??¬?´???°???????´????????????°
		int surplus = 1;
		
		while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		}
		System.out.println(max);// ?????§??¬?´???°?????????
	}
}