import java.util.Scanner;

public class Main{

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    }
} import java.util.Scanner; Scanner java.util public class Main{

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    }
} Main public static int gcd(int a,int b){
        if(b == 0){
            return a;
        }else{
            return gcd(b ,a % b);
        }
    } gcd {
        if(b == 0){
            return a;
        }else{
            return gcd(b ,a % b);
        }
    } if(b == 0){
            return a;
        }else{
            return gcd(b ,a % b);
        } b == 0 b 0 {
            return a;
        } return a; a {
            return gcd(b ,a % b);
        } return gcd(b ,a % b); gcd(b ,a % b) gcd b a % b a b int a a int b b public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    } main {
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a a b b x; x a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc x = gcd(a ,b) x gcd(a ,b) gcd a b System.out.printf("%d\n",x) System.out.printf System.out System System.out "%d\n" x String[] args args public class Main{

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    }
} public class Main{

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    }
} Main
import java.util.Scanner;

public class Main{

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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a ,b ,x;
        a = sc.nextInt();
        b = sc.nextInt();

        x = gcd(a ,b);

        System.out.printf("%d\n",x);
    }
}
