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