import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x= sc.nextInt(); x sc.nextInt() sc.nextInt sc int y= sc.nextInt(); y sc.nextInt() sc.nextInt sc while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        } true {
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        } if(x>=y){
                x%=y;
            }else{
                y%=x;
            } x>=y x y {
                x%=y;
            } x%=y x y {
                y%=x;
            } y%=x y x if(x*y==0){
                break;
            } x*y==0 x*y x y 0 {
                break;
            } break; System.out.println(x+y) System.out.println System.out System System.out x+y x y sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    }
}
