import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    }

} Main /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    } main {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    } BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in)); reader new BufferedReader(new InputStreamReader(
         System.in)) String arrStr = reader.readLine(); arrStr reader.readLine() reader.readLine reader StringTokenizer tokenizer = new StringTokenizer(arrStr, " "); tokenizer new StringTokenizer(arrStr, " ") int a = Integer.parseInt(tokenizer.nextToken()); a Integer.parseInt(tokenizer.nextToken()) Integer.parseInt Integer tokenizer.nextToken() tokenizer.nextToken tokenizer int b = Integer.parseInt(tokenizer.nextToken()); b Integer.parseInt(tokenizer.nextToken()) Integer.parseInt Integer tokenizer.nextToken() tokenizer.nextToken tokenizer System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    } gcd {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    } int r; r while((r = m % n) != 0){
            m = n;
            n = r;
        } (r = m % n) != 0 (r = m % n) r m % n m n 0 {
            m = n;
            n = r;
        } m = n m n n = r n r return n; n int m m int n n public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    }

} public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

         BufferedReader reader = new BufferedReader(new InputStreamReader(
         System.in));
         String arrStr = reader.readLine();
         StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");

         int a = Integer.parseInt(tokenizer.nextToken());
         int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(gcd(a, b));
//        System.out.println(gcd(54, 20));
    }

    static int gcd(int m, int n) {
        
        int r;
        while((r = m % n) != 0){
            m = n;
            n = r;
        }
        return n;
    }

}