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

public class Main{
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    }

    private static int gcd(int a , int b){
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    }
} import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.BufferedReader; BufferedReader 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(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    }

    private static int gcd(int a , int b){
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    }
} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    } 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 a = Integer.valueOf(input[0]); a Integer.valueOf(input[0]) Integer.valueOf Integer input[0] input 0 int b = Integer.parseInt(input[1]); b Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 System.out.println(gcd(a,b)) System.out.println System.out System System.out gcd(a,b) gcd a b String[] args args private static int gcd(int a , int b){
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    } gcd {
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    } int result = 1; result 1 if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        } b > a b a {
            int tmp = b;
            b = a;
            a = tmp;
        } int tmp = b; tmp b b = a b a a = tmp a tmp if((a % b) == 0) return b;
        else return gcd(b , a%b); (a % b) == 0 (a % b) a b 0 return b; b return gcd(b , a%b); gcd(b , a%b) gcd b a%b a b int a a int b b public class Main{
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    }

    private static int gcd(int a , int b){
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    }
} public class Main{
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    }

    private static int gcd(int a , int b){
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    }
} Main
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int a = Integer.valueOf(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(gcd(a,b));

    }

    private static int gcd(int a , int b){
        int result = 1;

        if(b > a){
            int tmp = b;
            b = a;
            a = tmp;
        }

        if((a % b) == 0) return b;
        else return gcd(b , a%b);
        
    }
}