import java.util.Scanner;

public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y){
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y){
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    }

} Main public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    } main {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int y = scanner.nextInt(); y scanner.nextInt() scanner.nextInt scanner System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args public static int gcd(int x, int y){
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    } gcd {
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    } int X = x X x Y = y; Y y if(X < Y) {
            X = y;
            Y = x;
        } X < Y X Y {
            X = y;
            Y = x;
        } X = y X y Y = x Y x if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y); X % Y == 0 X % Y X Y 0 return Y; Y return gcd(Y, X % Y); gcd(Y, X % Y) gcd Y X % Y X Y int x x int y y public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y){
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    }

} public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y){
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y){
        int X = x, Y = y;
        if(X < Y) {
            X = y;
            Y = x;
        }
        if(X % Y == 0)
            return Y;
        else
            return gcd(Y, X % Y);
    }

}
