import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        long x, y, r, temp;

        x = stdIn.nextLong();
        y = stdIn.nextLong();

        if (x < y) {
            temp = x;
            x = y;
            y = temp;
        }

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

 import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        long x, y, r, temp;

        x = stdIn.nextLong();
        y = stdIn.nextLong();

        if (x < y) {
            temp = x;
            x = y;
            y = temp;
        }

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

        long x, y, r, temp;

        x = stdIn.nextLong();
        y = stdIn.nextLong();

        if (x < y) {
            temp = x;
            x = y;
            y = temp;
        }

        while((r = x % y) != 0) {
            x = y;
            y = r;
        }
        System.out.println(y);
    } main {
        Scanner stdIn = new Scanner(System.in);

        long x, y, r, temp;

        x = stdIn.nextLong();
        y = stdIn.nextLong();

        if (x < y) {
            temp = x;
            x = y;
            y = temp;
        }

        while((r = x % y) != 0) {
            x = y;
            y = r;
        }
        System.out.println(y);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) long x x y y r r temp; temp x = stdIn.nextLong() x stdIn.nextLong() stdIn.nextLong stdIn y = stdIn.nextLong() y stdIn.nextLong() stdIn.nextLong stdIn if (x < y) {
            temp = x;
            x = y;
            y = temp;
        } x < y x y {
            temp = x;
            x = y;
            y = temp;
        } temp = x temp x x = y x y y = temp y temp while((r = x % y) != 0) {
            x = y;
            y = r;
        } (r = x % y) != 0 (r = x % y) r x % y x y 0 {
            x = y;
            y = r;
        } x = y x y y = r y r System.out.println(y) System.out.println System.out System System.out y String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        long x, y, r, temp;

        x = stdIn.nextLong();
        y = stdIn.nextLong();

        if (x < y) {
            temp = x;
            x = y;
            y = temp;
        }

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


