import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int x,y,temp;
	
	Scanner scan = new Scanner(System.in);
	x = scan.nextInt();
	y = scan.nextInt();
	
      	if(1>x || x>1000000000){System.exit(0);}
	if(1>y || y>1000000000){System.exit(0);}
	
	if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	}
    }
}
 import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
	int x,y,temp;
	
	Scanner scan = new Scanner(System.in);
	x = scan.nextInt();
	y = scan.nextInt();
	
      	if(1>x || x>1000000000){System.exit(0);}
	if(1>y || y>1000000000){System.exit(0);}
	
	if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	}
    }
} Main public static void main(String[] args){
	int x,y,temp;
	
	Scanner scan = new Scanner(System.in);
	x = scan.nextInt();
	y = scan.nextInt();
	
      	if(1>x || x>1000000000){System.exit(0);}
	if(1>y || y>1000000000){System.exit(0);}
	
	if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	}
    } main {
	int x,y,temp;
	
	Scanner scan = new Scanner(System.in);
	x = scan.nextInt();
	y = scan.nextInt();
	
      	if(1>x || x>1000000000){System.exit(0);}
	if(1>y || y>1000000000){System.exit(0);}
	
	if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	}
    } int x x y y temp; temp Scanner scan = new Scanner(System.in); scan new Scanner(System.in) x = scan.nextInt() x scan.nextInt() scan.nextInt scan y = scan.nextInt() y scan.nextInt() scan.nextInt scan if(1>x || x>1000000000){System.exit(0);} 1>x || x>1000000000 1>x 1 x x>1000000000 x 1000000000 {System.exit(0);} System.exit(0) System.exit System 0 if(1>y || y>1000000000){System.exit(0);} 1>y || y>1000000000 1>y 1 y y>1000000000 y 1000000000 {System.exit(0);} System.exit(0) System.exit System 0 if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	} x>=y x y {
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	} while((temp = x%y) != 0){
		x = y;
		y = temp;
	    } (temp = x%y) != 0 (temp = x%y) temp x%y x y 0 {
		x = y;
		y = temp;
	    } x = y x y y = temp y temp System.out.println(y) System.out.println System.out System System.out y {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	} while((temp = y%x)!=0){
		y = x;
		x = temp;
	    } (temp = y%x)!=0 (temp = y%x) temp y%x y x 0 {
		y = x;
		x = temp;
	    } y = x y x x = temp x temp System.out.println(x) System.out.println System.out System System.out x String[] args args
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int x,y,temp;
	
	Scanner scan = new Scanner(System.in);
	x = scan.nextInt();
	y = scan.nextInt();
	
      	if(1>x || x>1000000000){System.exit(0);}
	if(1>y || y>1000000000){System.exit(0);}
	
	if(x>=y){
	    while((temp = x%y) != 0){
		x = y;
		y = temp;
	    }
	    System.out.println(y);
	}
	else {
	    while((temp = y%x)!=0){
		y = x;
		x = temp;
	    }
	    System.out.println(x);
	}
    }
}

