import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    }
    static int gcd (int a, int b) {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    }
    static int gcd (int a, int b) {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc System.out.println(gcd(a, b)) System.out.println System.out System System.out gcd(a, b) gcd a b String[] args args static int gcd (int a, int b) {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    } gcd {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    } int num; num while((num = a%b)!=0) {
            a = b;
            b = num;
        } (num = a%b)!=0 (num = a%b) num a%b a b 0 {
            a = b;
            b = num;
        } a = b a b b = num b num return b; b int a a int b b public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    }
    static int gcd (int a, int b) {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    }
    static int gcd (int a, int b) {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(gcd(a, b));
    }
    static int gcd (int a, int b) {
        int num;
        while((num = a%b)!=0) {
            a = b;
            b = num;
        }
        return b;
    }

}
