import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    }
    
    public static int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    }
    
    public static int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    } 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 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 int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    } gcd {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    } int tmp = x % y; tmp x % y x y if (tmp == 0) {
            return y;
        } tmp == 0 tmp 0 {
            return y;
        } return y; y return gcd(y, tmp); gcd(y, tmp) gcd y tmp int x x int y y public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    }
    
    public static int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    }
    
    public static int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    }
    
    public static int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    }
}