import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z;
		//??????????????????????????????
		//??´??° x, y(x >= y)??????????????? x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
		//????????§ x % y ??? x ??? y ??§?????£???????????§??????
		do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0);
	}
} import java.util.*; util.* java class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z;
		//??????????????????????????????
		//??´??° x, y(x >= y)??????????????? x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
		//????????§ x % y ??? x ??? y ??§?????£???????????§??????
		do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0);
	}
} Main public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z;
		//??????????????????????????????
		//??´??° x, y(x >= y)??????????????? x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
		//????????§ x % y ??? x ??? y ??§?????£???????????§??????
		do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0);
	} main {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z;
		//??????????????????????????????
		//??´??° x, y(x >= y)??????????????? x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
		//????????§ x % y ??? x ??? y ??§?????£???????????§??????
		do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0);
	} 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 z; z do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0); z != 0 z 0 {
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		} z = Math.max(x, y) % Math.min(x, y) z Math.max(x, y) % Math.min(x, y) Math.max(x, y) Math.max Math x y Math.min(x, y) Math.min Math x y if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			} z == 0 z 0 {
				System.out.println(Math.min(x, y));
			} System.out.println(Math.min(x, y)) System.out.println System.out System System.out Math.min(x, y) Math.min Math x y {
				if(x > y){x = z;}
				else{y = z;}
			} if(x > y){x = z;}
				else{y = z;} x > y x y {x = z;} x = z x z {y = z;} y = z y z String args[] args
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z;
		//??????????????????????????????
		//??´??° x, y(x >= y)??????????????? x ??¨ y ????????§??¬?´???°??? y ??¨ x % y ????????§??¬?´???°???????????????
		//????????§ x % y ??? x ??? y ??§?????£???????????§??????
		do{
			z = Math.max(x, y) % Math.min(x, y);
			if(z == 0){
				System.out.println(Math.min(x, y));
			}
			else{
				if(x > y){x = z;}
				else{y = z;}
			}
		}while(z != 0);
	}
}