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();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    }

    public static int CalculateGCD(int x, int y) {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % 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();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    }

    public static int CalculateGCD(int x, int y) {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % y);
        }
    }
} Main public static void main(String[] args) {
        int x, y;
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        y = sc.nextInt();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    } main {
        int x, y;
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        y = sc.nextInt();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    } 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 System.out.println(CalculateGCD(x, y)) System.out.println System.out System System.out CalculateGCD(x, y) CalculateGCD x y sc.close() sc.close sc String[] args args public static int CalculateGCD(int x, int y) {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % y);
        }
    } CalculateGCD {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % y);
        }
    } if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        } x < y x y {
            int temp;
            temp = x;
            x = y;
            y = temp;
        } int temp; temp temp = x temp x x = y x y y = temp y temp if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % y);
        } x % y == 0 x % y x y 0 {
            return y;
        } return y; y {
            return CalculateGCD(y, x % y);
        } return CalculateGCD(y, x % y); CalculateGCD(y, x % y) CalculateGCD y x % y x y int x x int y 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();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    }

    public static int CalculateGCD(int x, int y) {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % 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();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    }

    public static int CalculateGCD(int x, int y) {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % 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();
        System.out.println(CalculateGCD(x, y));
        sc.close();
    }

    public static int CalculateGCD(int x, int y) {
        if (x < y) {
            int temp;
            temp = x;
            x = y;
            y = temp;
        }
        if (x % y == 0) {
            return y;
        } else {
            return CalculateGCD(y, x % y);
        }
    }
}
