import java.util.Scanner;

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

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        int x, y;
        Scanner sc = new Scanner(System.in);

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    }
} Main public static void main(String[] args) {
        int x, y;
        Scanner sc = new Scanner(System.in);

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    } main {
        int x, y;
        Scanner sc = new Scanner(System.in);

        x = sc.nextInt();
        y = sc.nextInt();

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

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    }
} public class Main {
    public static void main(String[] args) {
        int x, y;
        Scanner sc = new Scanner(System.in);

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    }
} Main
import java.util.Scanner;

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

        x = sc.nextInt();
        y = sc.nextInt();

        while (x % y != 0) {
            x%=y;
            int tmp = y;
            y = x;
            x = tmp;
        }
        System.out.println(y);
    }
}

