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