import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    } 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 xx = 0 xx 0 yy = 0; yy 0 while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        } y != 0 y 0 {
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        } if(x <= y){
            int t = x;
            x = y;
            y = t;
        } x <= y x y {
            int t = x;
            x = y;
            y = t;
        } int t = x; t x x = y x y y = t y t xx = y xx y yy = x % y yy x % y x y x = xx x xx y = yy y yy System.out.println(xx) System.out.println System.out System System.out xx sc.close() sc.close sc String[] args args public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    }
} public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int xx = 0, yy = 0;

        while(y != 0){
        if(x <= y){
            int t = x;
            x = y;
            y = t;
        }

        xx = y;
        yy = x % y;

        x = xx;
        y = yy;
        }
        
        System.out.println(xx);

        sc.close();
    }
}
