import java.util.*;
 
class Main {
    public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int i = sc.nextInt();
                int j = sc.nextInt();
        System.out.println(getGDC(i, j));
    }
 
    private static int getGDC(int i, int j) {
        if (j == 0) return i;
        return getGDC(j, i % j);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int i = sc.nextInt();
                int j = sc.nextInt();
        System.out.println(getGDC(i, j));
    }
 
    private static int getGDC(int i, int j) {
        if (j == 0) return i;
        return getGDC(j, i % j);
    }
} Main public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int i = sc.nextInt();
                int j = sc.nextInt();
        System.out.println(getGDC(i, j));
    } main {
                Scanner sc = new Scanner(System.in);
                int i = sc.nextInt();
                int j = sc.nextInt();
        System.out.println(getGDC(i, j));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i = sc.nextInt(); i sc.nextInt() sc.nextInt sc int j = sc.nextInt(); j sc.nextInt() sc.nextInt sc System.out.println(getGDC(i, j)) System.out.println System.out System System.out getGDC(i, j) getGDC i j String[] args args private static int getGDC(int i, int j) {
        if (j == 0) return i;
        return getGDC(j, i % j);
    } getGDC {
        if (j == 0) return i;
        return getGDC(j, i % j);
    } if (j == 0) return i; j == 0 j 0 return i; i return getGDC(j, i % j); getGDC(j, i % j) getGDC j i % j i j int i i int j j
import java.util.*;
 
class Main {
    public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int i = sc.nextInt();
                int j = sc.nextInt();
        System.out.println(getGDC(i, j));
    }
 
    private static int getGDC(int i, int j) {
        if (j == 0) return i;
        return getGDC(j, i % j);
    }
}