import java.util.Scanner;
class Main {
    public static void main( String[] args ) {
Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int r ;

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

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

        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        System.out.println(b);
    } main {
Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int r ;

        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        System.out.println(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 int r ; r while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        } (r = a % b) != 0 (r = a % b) r a % b a b 0 {
            a = b;
            b = r;
        } a = b a b b = r b r System.out.println(b) System.out.println System.out System System.out b String[] args args
import java.util.Scanner;
class Main {
    public static void main( String[] args ) {
Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int r ;

        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        System.out.println(b);
    }
}
