import java.util.*;

public class Main {
    public static final int CONSTRAINT = 1000000000;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    }
}

class GreatestCommonDivisor{
    // int GCD;    //Greatest Common Divisor 
    public int getGCD(int maxNum, int minNum){
        if(minNum == 0){
            return maxNum;
        }else{
            return getGCD(minNum, (maxNum % minNum));
        }
    }
} import java.util.*; util.* java public class Main {
    public static final int CONSTRAINT = 1000000000;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    }
} Main public static final int CONSTRAINT = 1000000000; CONSTRAINT 1000000000 public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc int maxNum = Math.max(x,y); maxNum Math.max(x,y) Math.max Math x y int minNum = Math.min(x,y); minNum Math.min(x,y) Math.min Math x y GreatestCommonDivisor GCD = new GreatestCommonDivisor(); GCD new GreatestCommonDivisor() System.out.println(GCD.getGCD(maxNum, minNum)) System.out.println System.out System System.out GCD.getGCD(maxNum, minNum) GCD.getGCD GCD maxNum minNum String[] args args class GreatestCommonDivisor{
    // int GCD;    //Greatest Common Divisor 
    public int getGCD(int maxNum, int minNum){
        if(minNum == 0){
            return maxNum;
        }else{
            return getGCD(minNum, (maxNum % minNum));
        }
    }
} GreatestCommonDivisor // int GCD;    //Greatest Common Divisor 
    public int getGCD(int maxNum, int minNum){
        if(minNum == 0){
            return maxNum;
        }else{
            return getGCD(minNum, (maxNum % minNum));
        }
    } getGCD {
        if(minNum == 0){
            return maxNum;
        }else{
            return getGCD(minNum, (maxNum % minNum));
        }
    } if(minNum == 0){
            return maxNum;
        }else{
            return getGCD(minNum, (maxNum % minNum));
        } minNum == 0 minNum 0 {
            return maxNum;
        } return maxNum; maxNum {
            return getGCD(minNum, (maxNum % minNum));
        } return getGCD(minNum, (maxNum % minNum)); getGCD(minNum, (maxNum % minNum)) getGCD minNum (maxNum % minNum) maxNum minNum int maxNum maxNum int minNum minNum public class Main {
    public static final int CONSTRAINT = 1000000000;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    }
} public class Main {
    public static final int CONSTRAINT = 1000000000;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    }
} Main
import java.util.*;

public class Main {
    public static final int CONSTRAINT = 1000000000;
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int maxNum = Math.max(x,y);
        int minNum = Math.min(x,y);
        
        GreatestCommonDivisor GCD = new GreatestCommonDivisor();
        System.out.println(GCD.getGCD(maxNum, minNum));
    }
}

class GreatestCommonDivisor{
    // int GCD;    //Greatest Common Divisor 
    public int getGCD(int maxNum, int minNum){
        if(minNum == 0){
            return maxNum;
        }else{
            return getGCD(minNum, (maxNum % minNum));
        }
    }
}
