import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int temp = 0;

		if(b > a){
			temp = a;
			a = b; 
			b = temp;
		}

		if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		}
		

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int temp = 0;

		if(b > a){
			temp = a;
			a = b; 
			b = temp;
		}

		if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		}
		

	}
} Main public static void main(String[] args)throws Exception{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int temp = 0;

		if(b > a){
			temp = a;
			a = b; 
			b = temp;
		}

		if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		}
		

	} main {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int temp = 0;

		if(b > a){
			temp = a;
			a = b; 
			b = temp;
		}

		if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		}
		

	} BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner int temp = 0; temp 0 if(b > a){
			temp = a;
			a = b; 
			b = temp;
		} b > a b a {
			temp = a;
			a = b; 
			b = temp;
		} temp = a temp a a = b a b b = temp b temp if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		} a == b a b {
			System.out.println(b);
		} System.out.println(b) System.out.println System.out System System.out b {
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		} while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			} a % b != 0 a % b a b 0 {
				temp = b;
				b = a % b;
				a = temp;
			} temp = b temp b b = a % b b a % b a b a = temp a temp System.out.println(b) System.out.println System.out System System.out b String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int temp = 0;

		if(b > a){
			temp = a;
			a = b; 
			b = temp;
		}

		if(a == b){
			System.out.println(b);
		}else{
			while(a % b != 0){
				temp = b;
				b = a % b;
				a = temp;
			}
			System.out.println(b);
		}
		

	}
}