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