import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    }
    
    public static int gcd(int x, int y){
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    }
    
    public static int gcd(int x, int y){
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    } main {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] num = new int[2]; num new int[2] 2 for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < num.length i num.length num num.length i++ i++ i {
            num[i] = sc.nextInt();
        } {
            num[i] = sc.nextInt();
        } num[i] = sc.nextInt() num[i] num i sc.nextInt() sc.nextInt sc System.out.println(gcd(num[0],num[1])) System.out.println System.out System System.out gcd(num[0],num[1]) gcd num[0] num 0 num[1] num 1 String[] args args public static int gcd(int x, int y){
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    } gcd {
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    } int r; r if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        } x < y x y {
            int tmp = x;
            x = y;
            y = tmp;
        } int tmp = x; tmp x x = y x y y = tmp y tmp while(y > 0){
            r = x % y;
            x = y;
            y = r;
        } y > 0 y 0 {
            r = x % y;
            x = y;
            y = r;
        } r = x % y r x % y x y x = y x y y = r y r return x; x int x x int y y public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    }
    
    public static int gcd(int x, int y){
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    }
    
    public static int gcd(int x, int y){
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[2];

        for(int i = 0; i < num.length; i++){
            num[i] = sc.nextInt();
        }

        System.out.println(gcd(num[0],num[1]));
    }
    
    public static int gcd(int x, int y){
        int r;
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
}
