import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

        while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

        while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        }
    }
} Main public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

        while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        }
    } main {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

        while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] a = sc.nextLine().split(" "); a sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int x = Integer.parseInt(a[0]); x Integer.parseInt(a[0]) Integer.parseInt Integer a[0] a 0 int y = Integer.parseInt(a[1]); y Integer.parseInt(a[1]) Integer.parseInt Integer a[1] a 1 while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        } true {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        } if (x % y == 0) {
                System.out.println(y);
                break;
            } x % y == 0 x % y x y 0 {
                System.out.println(y);
                break;
            } System.out.println(y) System.out.println System.out System System.out y break; int tmp = x; tmp x x = y x y y = tmp % y y tmp % y tmp y String[] args args public class Main {
    public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

        while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        }
    }
} public class Main {
    public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

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

public class Main {
    public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

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