import java.io.*;

class Main{
        static void sort(int[] A){
                if(A[0]<A[1]){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                }
        }
        public static void main(String[] args) throws IOException{
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String s[] = br.readLine().split(" ");
                int A[] = {0, 0};

                for(int i=0; i<2; i++)
                        A[i] = Integer.parseInt(s[i]);
                sort(A);
                while((A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1])){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                }
                System.out.println(A[0]);
        }
} import java.io.*; io.* java class Main{
        static void sort(int[] A){
                if(A[0]<A[1]){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                }
        }
        public static void main(String[] args) throws IOException{
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String s[] = br.readLine().split(" ");
                int A[] = {0, 0};

                for(int i=0; i<2; i++)
                        A[i] = Integer.parseInt(s[i]);
                sort(A);
                while((A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1])){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                }
                System.out.println(A[0]);
        }
} Main static void sort(int[] A){
                if(A[0]<A[1]){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                }
        } sort {
                if(A[0]<A[1]){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                }
        } if(A[0]<A[1]){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                } A[0]<A[1] A[0] A 0 A[1] A 1 {
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                } int t = A[0]; t A[0] A 0 A[0] = A[1] A[0] A 0 A[1] A 1 A[1] = t A[1] A 1 t int[] A A public static void main(String[] args) throws IOException{
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String s[] = br.readLine().split(" ");
                int A[] = {0, 0};

                for(int i=0; i<2; i++)
                        A[i] = Integer.parseInt(s[i]);
                sort(A);
                while((A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1])){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                }
                System.out.println(A[0]);
        } main {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String s[] = br.readLine().split(" ");
                int A[] = {0, 0};

                for(int i=0; i<2; i++)
                        A[i] = Integer.parseInt(s[i]);
                sort(A);
                while((A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1])){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                }
                System.out.println(A[0]);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s[] = br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int A[] = {0, 0}; A {0, 0} 0 0 for(int i=0; i<2; i++)
                        A[i] = Integer.parseInt(s[i]); int i=0; int i=0; i 0 i<2 i 2 i++ i++ i A[i] = Integer.parseInt(s[i]); A[i] = Integer.parseInt(s[i]) A[i] A i Integer.parseInt(s[i]) Integer.parseInt Integer s[i] s i sort(A) sort A while((A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1])){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                } (A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1]) (A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1]) (A[0]>1) A[0] A 0 1 A[1]!=0 A[1] A 1 0 (A[0]!=A[0]%A[1]) A[0] A 0 A[0]%A[1] A[0] A 0 A[1] A 1 {
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                } int t = A[0]; t A[0] A 0 A[0] = A[1] A[0] A 0 A[1] A 1 A[1] = t%A[1] A[1] A 1 t%A[1] t A[1] A 1 sort(A) sort A System.out.println(A[0]) System.out.println System.out System System.out A[0] A 0 String[] args args
import java.io.*;

class Main{
        static void sort(int[] A){
                if(A[0]<A[1]){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t;
                }
        }
        public static void main(String[] args) throws IOException{
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                String s[] = br.readLine().split(" ");
                int A[] = {0, 0};

                for(int i=0; i<2; i++)
                        A[i] = Integer.parseInt(s[i]);
                sort(A);
                while((A[0]>1)&&A[1]!=0&&(A[0]!=A[0]%A[1])){
                        int t = A[0];
                        A[0] = A[1];
                        A[1] = t%A[1];
                        sort(A);
                }
                System.out.println(A[0]);
        }
}