import java.io.*;
import java.util.*;



public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    }

    public static int run(int x,int y){
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    }
}
 import java.io.*; io.* java import java.util.*; util.* java public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    }

    public static int run(int x,int y){
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    }
} Main public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str str = br.readLine() str br.readLine() br.readLine br String[] line = str.split("\\s"); line str.split("\\s") str.split str "\\s" int x = Integer.parseInt(line[0]); x Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int y = Integer.parseInt(line[1]); y Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int temp = 0; temp 0 if(x > y){
            temp = y;
            y = x;
            x = temp;
        } x > y x y {
            temp = y;
            y = x;
            x = temp;
        } temp = y temp y y = x y x x = temp x temp temp = run(x,y) temp run(x,y) run x y System.out.println(temp) System.out.println System.out System System.out temp br.close() br.close br String[] args args public static int run(int x,int y){
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    } run {
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    } if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        } x == 0 x 0 {
            return y;
        } return y; y {
            int m = y % x;
            return run(m,x);
        } int m = y % x; m y % x y x return run(m,x); run(m,x) run m x int x x int y y public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    }

    public static int run(int x,int y){
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    }
} public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    }

    public static int run(int x,int y){
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    }
} Main
import java.io.*;
import java.util.*;



public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        String[] line = str.split("\\s");
        int x = Integer.parseInt(line[0]);
        int y = Integer.parseInt(line[1]);
     
        int temp = 0;
        if(x > y){
            temp = y;
            y = x;
            x = temp;
        }

        temp = run(x,y);

        System.out.println(temp);
       
        br.close();
    }

    public static int run(int x,int y){
        if(x == 0){
            return y;
        }else{
            int m = y % x;
            return run(m,x);
        }
    }
}

