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 a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    }
} 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 a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    } 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 a = Math.max(x,y); a Math.max(x,y) Math.max Math x y int b = Math.min(x,y); b Math.min(x,y) Math.min Math x y while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        } !(a ==0 || b == 0) (a ==0 || b == 0) a ==0 a 0 b == 0 b 0 {
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        } a = a%b a a%b a b if(a == 0){
                break;
            } a == 0 a 0 {
                break;
            } break; b = b%a b b%a b a System.out.println(Math.max(a,b)) System.out.println System.out System System.out Math.max(a,b) Math.max Math a b 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 a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    }
} 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 a = Math.max(x,y);
        int b = Math.min(x,y);
        while(!(a ==0 || b == 0)){
            a = a%b;
            if(a == 0){
                break;
            }
            b = b%a;
        }
        System.out.println(Math.max(a,b));
    }
}