import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    }
    
    static int gcd(int x, int y){
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    }
    
    static int gcd(int x, int y){
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = Integer.parseInt(sc.next()); x Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int y = Integer.parseInt(sc.next()); y Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc System.out.println(gcd(x, y)) System.out.println System.out System System.out gcd(x, y) gcd x y String[] args args static int gcd(int x, int y){
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    } gcd {
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    } if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        } x < y x y {
            int tmp = x;
            x = y;
            y = tmp;
        } int tmp = x; tmp x x = y x y y = tmp y tmp while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        } y > 0 y 0 {
            int r = x % y;
            x = y;
            y = r;
        } int r = x % y; r x % y x y x = y x y y = r y r return x; x int x x int y y public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    }
    
    static int gcd(int x, int y){
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    }
    
    static int gcd(int x, int y){
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
    
        System.out.println(gcd(x, y));
    }
    
    static int gcd(int x, int y){
        if(x < y){
            int tmp = x;
            x = y;
            y = tmp;
        }
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
}
