import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String string = reader.readLine();
        StringTokenizer token = new StringTokenizer(string," ");
        
        int x = Integer.parseInt((String)token.nextElement());
        int y = Integer.parseInt((String)token.nextElement());
        
        int answer = gcd(x,y);
        System.out.println(answer);
    }
    
    public static int gcd(int x,int y){
        
        int answer;
        
        if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        }
        return answer;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String string = reader.readLine();
        StringTokenizer token = new StringTokenizer(string," ");
        
        int x = Integer.parseInt((String)token.nextElement());
        int y = Integer.parseInt((String)token.nextElement());
        
        int answer = gcd(x,y);
        System.out.println(answer);
    }
    
    public static int gcd(int x,int y){
        
        int answer;
        
        if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        }
        return answer;
    }
} Main //読み込みのテンプレ(stringオブジェクトまで)
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String string = reader.readLine();
        StringTokenizer token = new StringTokenizer(string," ");
        
        int x = Integer.parseInt((String)token.nextElement());
        int y = Integer.parseInt((String)token.nextElement());
        
        int answer = gcd(x,y);
        System.out.println(answer);
    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String string = reader.readLine();
        StringTokenizer token = new StringTokenizer(string," ");
        
        int x = Integer.parseInt((String)token.nextElement());
        int y = Integer.parseInt((String)token.nextElement());
        
        int answer = gcd(x,y);
        System.out.println(answer);
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String string = reader.readLine(); string reader.readLine() reader.readLine reader StringTokenizer token = new StringTokenizer(string," "); token new StringTokenizer(string," ") int x = Integer.parseInt((String)token.nextElement()); x Integer.parseInt((String)token.nextElement()) Integer.parseInt Integer (String)token.nextElement() token.nextElement token int y = Integer.parseInt((String)token.nextElement()); y Integer.parseInt((String)token.nextElement()) Integer.parseInt Integer (String)token.nextElement() token.nextElement token int answer = gcd(x,y); answer gcd(x,y) gcd x y System.out.println(answer) System.out.println System.out System System.out answer String[] args args public static int gcd(int x,int y){
        
        int answer;
        
        if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        }
        return answer;
    } gcd {
        
        int answer;
        
        if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        }
        return answer;
    } int answer; answer if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        } x > y x y {
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        } while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            } x%y != 0 || y !=1 x%y != 0 x%y x y 0 y !=1 y 1 {
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            } int x_1 = x; x_1 x int y_1 = y; y_1 y x = y x y y = x_1 % y y x_1 % y x_1 y if(y == 0){
                    y = y_1;
                    break;
                } y == 0 y 0 {
                    y = y_1;
                    break;
                } y = y_1 y y_1 break; if(y == 1){
                answer = 1;
            }else{
                answer = y;
            } y == 1 y 1 {
                answer = 1;
            } answer = 1 answer 1 {
                answer = y;
            } answer = y answer y {
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        } int x_y = x; x_y x int y_x = y; y_x y x = y_x x y_x y = x_y y x_y while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            } x%y !=0 || y !=1 x%y !=0 x%y x y 0 y !=1 y 1 {
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            } int x_1 = x; x_1 x int y_1 = y; y_1 y x = y x y y = x_1 % y y x_1 % y x_1 y if(y == 0){
                    y = y_1;
                    break;
                } y == 0 y 0 {
                    y = y_1;
                    break;
                } y = y_1 y y_1 break; if(y == 1){
                answer = 1;
            }else{
                answer = y;
            } y == 1 y 1 {
                answer = 1;
            } answer = 1 answer 1 {
                answer = y;
            } answer = y answer y return answer; answer int x x int y y
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
    //読み込みのテンプレ(stringオブジェクトまで)
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String string = reader.readLine();
        StringTokenizer token = new StringTokenizer(string," ");
        
        int x = Integer.parseInt((String)token.nextElement());
        int y = Integer.parseInt((String)token.nextElement());
        
        int answer = gcd(x,y);
        System.out.println(answer);
    }
    
    public static int gcd(int x,int y){
        
        int answer;
        
        if(x > y){
            
            while(x%y != 0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
            
            
        }else{
            int x_y = x;
            int y_x = y;
            
            x = y_x;
            y = x_y;
            
            while(x%y !=0 || y !=1){
                int x_1 = x;
                int y_1 = y;
                x = y;
                y = x_1 % y;
                if(y == 0){
                    y = y_1;
                    break;
                }
            }
            if(y == 1){
                answer = 1;
            }else{
                answer = y;
            }
        
        }
        return answer;
    }
}