import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    }

    private static int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    }

    private static int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int z = gcd(sc.nextInt(), sc.nextInt()); z gcd(sc.nextInt(), sc.nextInt()) gcd sc.nextInt() sc.nextInt sc sc.nextInt() sc.nextInt sc System.out.println(z) System.out.println System.out System System.out z sc.close() sc.close sc String[] args args private static int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    } gcd {
        if (x == 0) return y;
        return gcd(y % x, x);
    } if (x == 0) return y; x == 0 x 0 return y; y return gcd(y % x, x); gcd(y % x, x) gcd y % x y x x int x x int y y public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    }

    private static int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    }

    private static int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int z = gcd(sc.nextInt(), sc.nextInt());
        System.out.println(z);
        sc.close();
    }

    private static int gcd(int x, int y) {
        if (x == 0) return y;
        return gcd(y % x, x);
    }
}

