import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.sql.Array;
import java.util.*;

public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    }
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.math.BigInteger; BigInteger java.math import java.sql.Array; Array java.sql import java.util.*; util.* java public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    }
} Main static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;} gcd {return b>0?gcd(b,a%b):a;} return b>0?gcd(b,a%b):a; b>0?gcd(b,a%b):a b>0 b 0 gcd(b,a%b) gcd b a%b a b a long a a long b b static long lcm (long a, long b) {return a*b/gcd(a,b);} lcm {return a*b/gcd(a,b);} return a*b/gcd(a,b); a*b/gcd(a,b) a*b a b gcd(a,b) gcd a b long a a long b b public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    } main {
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) long x=sc.nextLong() x sc.nextLong() sc.nextLong sc y=sc.nextLong(); y sc.nextLong() sc.nextLong sc System.out.println(gcd(x,y)) System.out.println System.out System System.out gcd(x,y) gcd x y String[] args args public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    }
} public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.sql.Array;
import java.util.*;

public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong(),y=sc.nextLong();
        System.out.println(gcd(x,y));
    }
}

