import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    } main {
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    } BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) String[] str=buf.readLine().split(" "); str buf.readLine().split(" ") buf.readLine().split buf.readLine() buf.readLine buf " " int x=Integer.parseInt(str[0]); x Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int y=Integer.parseInt(str[1]); y Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int ans=0 ans 0 flg=1; flg 1 if(x==y){
            System.out.println(x);
            flg=0;
        } x==y x y {
            System.out.println(x);
            flg=0;
        } System.out.println(x) System.out.println System.out System System.out x flg=0 flg 0 while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        } flg==1 flg 1 {
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        } ans=x%y ans x%y x y x=y x y y=ans y ans if(x%y==0){
                System.out.println(ans);break;
            } x%y==0 x%y x y 0 {
                System.out.println(ans);break;
            } System.out.println(ans) System.out.println System.out System System.out ans break; String[] args args public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    }
} public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    }
} Main
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    }
}