import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int jy = -1;
		int keisan = 0;
		if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		}
//		System.out.println(x+" "+y);
		while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		}
		System.out.println(x);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int jy = -1;
		int keisan = 0;
		if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		}
//		System.out.println(x+" "+y);
		while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		}
		System.out.println(x);
	}
} Main public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int jy = -1;
		int keisan = 0;
		if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		}
//		System.out.println(x+" "+y);
		while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		}
		System.out.println(x);
	} main {
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int jy = -1;
		int keisan = 0;
		if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		}
//		System.out.println(x+" "+y);
		while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		}
		System.out.println(x);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int y = scan.nextInt(); y scan.nextInt() scan.nextInt scan int jy = -1; jy -1 1 int keisan = 0; keisan 0 if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		} x < y x y {
			keisan = x;
			x = y;
			y = keisan;
		} keisan = x keisan x x = y x y y = keisan y keisan while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		} jy != 0 jy 0 {
			jy = x % y;
			x = y;
			y = jy;
		} jy = x % y jy x % y x y x = y x y y = jy y jy System.out.println(x) System.out.println System.out System System.out x String[] args args
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int jy = -1;
		int keisan = 0;
		if(x < y){
			keisan = x;
			x = y;
			y = keisan;
		}
//		System.out.println(x+" "+y);
		while(jy != 0){
			jy = x % y;
			x = y;
			y = jy;
		}
		System.out.println(x);
	}
}