import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    }
} Main public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    } main {
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    } Scanner am = new Scanner(System.in); am new Scanner(System.in) int x =am.nextInt(); x am.nextInt() am.nextInt am int y =am.nextInt(); y am.nextInt() am.nextInt am int c=1; c 1 while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    } true {
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    } if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        } x>y x y {
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        } x=x%y x x%y x y if(x==0){
                c=y;
                break;
            } x==0 x 0 {
                c=y;
                break;
            } c=y c y break; {
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        } y=y%x y y%x y x if(y==0){
                c=x;
                break;
            } y==0 y 0 {
                c=x;
                break;
            } c=x c x break; System.out.println(c) System.out.println System.out System System.out c am.close() am.close am String [] args args public class Main{
    public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    }
} public class Main{
    public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String [] args){
        Scanner am = new Scanner(System.in);
        int x =am.nextInt();
        int y =am.nextInt();
        int c=1;
        while(true){
        if(x>y){
            x=x%y;
            if(x==0){
                c=y;
                break;
            }
        }
        else{
            y=y%x;
            if(y==0){
                c=x;
                break;
            }
        }
        
    }

        /*for(int a=1;a<=x && a<=y;a++){
            if(x%a==0 && y%a==0)c=a;
        }
        */
        System.out.println(c);
      am.close();  
    }
}
