import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    }
    
    static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

} import java.io.*; io.* java public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    }
    
    static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int x = Integer.parseInt(input[0]); x Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int y = Integer.parseInt(input[1]); y Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 System.out.println(gcd(x,y)) System.out.println System.out System System.out gcd(x,y) gcd x y String[] args args static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    } gcd {
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    } int a = Math.max(x, y); a Math.max(x, y) Math.max Math x y int b = Math.min(x, y); b Math.min(x, y) Math.min Math x y while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        } b > 0 b 0 {
            int c = a % b;
            a = b;
            b = c;
        } int c = a % b; c a % b a b a = b a b b = c b c return a; a 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[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    }
    
    static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

} public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    }
    
    static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

} Main
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    }
    
    static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

}