import java.text.DecimalFormat;
import java.util.*;

public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        }
    }
} import java.text.DecimalFormat; DecimalFormat java.text import java.util.*; util.* java public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        }
    }
} Main public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%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 sc.close() sc.close sc int tmp = 0; tmp 0 while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        } true {
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        } if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            } a%b==0||b==1 a%b==0 a%b a b 0 b==1 b 1 {
                System.out.println(b);
                break;
            } System.out.println(b) System.out.println System.out System System.out b break; {
                tmp = a;
                a = b;
                b = tmp%b;
            } tmp = a tmp a a = b a b b = tmp%b b tmp%b tmp b String[] args args public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        }
    }
} public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        }
    }
} Main
import java.text.DecimalFormat;
import java.util.*;

public class Main {
    public static void main(String[] args)  throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int tmp = 0;
        while (true){
            if(a%b==0||b==1){
                System.out.println(b);
                break;
            }else{
                tmp = a;
                a = b;
                b = tmp%b;
            }
        }
    }
}