import java.util.Scanner;
 
 class Main {
    public static void main(String[] args){ 
        
         Scanner shuru = new Scanner(System.in);   

        
        int a = shuru.nextInt();
        
        int b = shuru.nextInt();
        int hhh = a;
        
        for( int i = 1;i <= hhh;i ++){

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        }


}
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args){ 
        
         Scanner shuru = new Scanner(System.in);   

        
        int a = shuru.nextInt();
        
        int b = shuru.nextInt();
        int hhh = a;
        
        for( int i = 1;i <= hhh;i ++){

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        }


}
} Main public static void main(String[] args){ 
        
         Scanner shuru = new Scanner(System.in);   

        
        int a = shuru.nextInt();
        
        int b = shuru.nextInt();
        int hhh = a;
        
        for( int i = 1;i <= hhh;i ++){

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        }


} main { 
        
         Scanner shuru = new Scanner(System.in);   

        
        int a = shuru.nextInt();
        
        int b = shuru.nextInt();
        int hhh = a;
        
        for( int i = 1;i <= hhh;i ++){

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        }


} Scanner shuru = new Scanner(System.in); shuru new Scanner(System.in) int a = shuru.nextInt(); a shuru.nextInt() shuru.nextInt shuru int b = shuru.nextInt(); b shuru.nextInt() shuru.nextInt shuru int hhh = a; hhh a for( int i = 1;i <= hhh;i ++){

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        } int i = 1; int i = 1; i 1 i <= hhh i hhh i ++ i ++ i {

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        } {

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        } int c = a > b ? a : b; c a > b ? a : b a > b a b a b int d = a < b ? a : b; d a < b ? a : b a < b a b a b a = c % d a c % d c d b = d b d if(a == 0) {
                System.out.println(d);
                return;
            } a == 0 a 0 {
                System.out.println(d);
                return;
            } System.out.println(d) System.out.println System.out System System.out d return; String[] args args
import java.util.Scanner;
 
 class Main {
    public static void main(String[] args){ 
        
         Scanner shuru = new Scanner(System.in);   

        
        int a = shuru.nextInt();
        
        int b = shuru.nextInt();
        int hhh = a;
        
        for( int i = 1;i <= hhh;i ++){

        int c = a > b ? a : b;
            int d = a < b ? a : b;

            a = c % d;
            b = d;

            if(a == 0) {
                System.out.println(d);
                return;
            }

        }


}
}
