
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    }
    public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    }

}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    }
    public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    }

} Main public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    } main {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    } Scanner scanner =new Scanner(System.in); scanner new Scanner(System.in) long x=scanner.nextLong(); x scanner.nextLong() scanner.nextLong scanner long y=scanner.nextLong(); y scanner.nextLong() scanner.nextLong scanner System.out.println(gcd(x,y)) System.out.println System.out System System.out gcd(x,y) gcd x y String[] args args public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    } gcd {
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    } long minXY=Math.min(x,y); minXY Math.min(x,y) Math.min Math x y long maxXY=Math.max(x,y); maxXY Math.max(x,y) Math.max Math x y long z=maxXY%minXY; z maxXY%minXY maxXY minXY if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        } z==0 z 0 {
            return minXY;
        } return minXY; minXY {
            return gcd(minXY,z);
        } return gcd(minXY,z); gcd(minXY,z) gcd minXY z long x x long y y public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    }
    public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    }

} public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    }
    public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    }

} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner =new Scanner(System.in);
        long x=scanner.nextLong();
        long y=scanner.nextLong();
        System.out.println(gcd(x,y));
    }
    public static long gcd(long x,long y){
        long minXY=Math.min(x,y);
        long maxXY=Math.max(x,y);
        long z=maxXY%minXY;
        if(z==0){
            return minXY;
        }else{
            return gcd(minXY,z);
        }
    }

}

