import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    }

    private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    }

    private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    } main {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] a = new int[]{sc.nextInt(), sc.nextInt()}; a new int[]{sc.nextInt(), sc.nextInt()} System.out.println(greatestCommonDivisor(a[0], a[1])) System.out.println System.out System System.out greatestCommonDivisor(a[0], a[1]) greatestCommonDivisor a[0] a 0 a[1] a 1 String[] args args private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    } greatestCommonDivisor {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    } int big big small; small if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        } a == b a b {
            return a;
        } return a; a if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        } a > b a b {
            big = a;
            small = b;
        } big = a big a small = b small b {
            big = b;
            small = a;
        } big = b big b small = a small a while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        } true {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        } int x = big % small; x big % small big small if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            } x == 0 x 0 {
                return small;
            } return small; small {
                big = small;
                small = x;
            } big = small big small small = x small x int a a int b b public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    }

    private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    }

    private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt()};
        System.out.println(greatestCommonDivisor(a[0], a[1]));
    }

    private static int greatestCommonDivisor(int a, int b) {
        int big, small;
        if (a == b) {
            return a;
        } else if (a > b) {
            big = a;
            small = b;
        } else {
            big = b;
            small = a;
        }

        while (true) {
            int x = big % small;
            if (x == 0) {
                return small;
            } else {
                big = small;
                small = x;
            }
        }
    }
}