import java.util.*;

public class Main {

    static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

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

    static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

    static int gcd(int x, int y) {
        if(x % y == 0) return y;
        else return gcd(y, x % y);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x < y) swap(x, y);
        System.out.println(gcd(x, y));
    }
} Main static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    } swap {
        int tmp = a;
        a = b;
        b = tmp;
    } int tmp = a; tmp a a = b a b b = tmp b tmp int a a int b b static int gcd(int x, int y) {
        if(x % y == 0) return y;
        else return gcd(y, x % y);
    } gcd {
        if(x % y == 0) return y;
        else return gcd(y, x % y);
    } 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 static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x < y) swap(x, y);
        System.out.println(gcd(x, y));
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(x < y) swap(x, y);
        System.out.println(gcd(x, y));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc if(x < y) swap(x, y); x < y x y swap(x, y) swap x y System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args public class Main {

    static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

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

    static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

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

public class Main {

    static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }

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