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

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String in = br.readLine();
        final int x = Integer.parseInt(in.substring(0, in.indexOf(' ')));
        final int y = Integer.parseInt(in.substring(in.indexOf(' ')+1));
        System.out.println(gcd(x, y));
    }
    private static int gcd(int x, int y){
        while(true){
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String in = br.readLine();
        final int x = Integer.parseInt(in.substring(0, in.indexOf(' ')));
        final int y = Integer.parseInt(in.substring(in.indexOf(' ')+1));
        System.out.println(gcd(x, y));
    }
    private static int gcd(int x, int y){
        while(true){
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        }
    }
} Main public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String in = br.readLine();
        final int x = Integer.parseInt(in.substring(0, in.indexOf(' ')));
        final int y = Integer.parseInt(in.substring(in.indexOf(' ')+1));
        System.out.println(gcd(x, y));
    } main {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String in = br.readLine();
        final int x = Integer.parseInt(in.substring(0, in.indexOf(' ')));
        final int y = Integer.parseInt(in.substring(in.indexOf(' ')+1));
        System.out.println(gcd(x, y));
    } final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) final String in = br.readLine(); in br.readLine() br.readLine br final int x = Integer.parseInt(in.substring(0, in.indexOf(' '))); x Integer.parseInt(in.substring(0, in.indexOf(' '))) Integer.parseInt Integer in.substring(0, in.indexOf(' ')) in.substring in 0 in.indexOf(' ') in.indexOf in ' ' final int y = Integer.parseInt(in.substring(in.indexOf(' ')+1)); y Integer.parseInt(in.substring(in.indexOf(' ')+1)) Integer.parseInt Integer in.substring(in.indexOf(' ')+1) in.substring in in.indexOf(' ')+1 in.indexOf(' ') in.indexOf in ' ' 1 System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args private static int gcd(int x, int y){
        while(true){
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        }
    } gcd {
        while(true){
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        }
    } while(true){
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        } true {
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        } x %= y x y if(x==0)
                return y; x==0 x 0 return y; y y %= x y x if(y==0)
                return x; y==0 y 0 return x; x int x x int y y
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String in = br.readLine();
        final int x = Integer.parseInt(in.substring(0, in.indexOf(' ')));
        final int y = Integer.parseInt(in.substring(in.indexOf(' ')+1));
        System.out.println(gcd(x, y));
    }
    private static int gcd(int x, int y){
        while(true){
            x %= y;
            if(x==0)
                return y;
            y %= x;
            if(y==0)
                return x;
        }
    }
}