import java.util.*;

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