import java.util.Scanner;

public class Main{
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    }
} Main public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    } main {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner int gcd; gcd while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        } true {
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        } if(a > b){
                int c = a;
                a = b;
                b = c;
            } a > b a b {
                int c = a;
                a = b;
                b = c;
            } int c = a; c a a = b a b b = c b c if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            } b % a == 0 b % a b a 0 {
                gcd = a;
                break;
            } gcd = a gcd a break; {
                b = b % a;
            } b = b % a b b % a b a System.out.println(gcd) System.out.println System.out System System.out gcd scanner.close() scanner.close scanner final String[] args args public class Main{
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    }
} public class Main{
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(final String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int gcd;
        while(true){
            if(a > b){
                int c = a;
                a = b;
                b = c;
            }
            if(b % a == 0){
                gcd = a;
                break;
            }else{
                b = b % a;
            }
        }
        System.out.println(gcd);
        scanner.close();
    }
}
