import java.util.*;

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

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