import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	}

}
 import java.util.Scanner; Scanner java.util public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	}

} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i i x x y y tmp; tmp x = sc.nextInt() x sc.nextInt() sc.nextInt sc y = sc.nextInt() y sc.nextInt() sc.nextInt sc if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		} y>x y x {
			tmp = x;
			x = y;
			y = tmp;
		} tmp = x tmp x x = y x y y = tmp y tmp while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		} true {
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		} if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			} x%y == 0 x%y x y 0 {
				System.out.println(y);
				System.exit(0);
			} System.out.println(y) System.out.println System.out System System.out y System.exit(0) System.exit System 0 tmp = y tmp y y = x % y y x % y x y x = tmp x tmp String[] args args public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	}

} public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	}

} Main
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int i,x,y,tmp;
		
		x = sc.nextInt();
		y = sc.nextInt();
		
		if(y>x){
			tmp = x;
			x = y;
			y = tmp;
		}
		while(true){
			if(x%y == 0) {
				System.out.println(y);
				System.exit(0);
			}
			tmp = y;
			y = x % y;
			x = tmp;
		}
	}

}

