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();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%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();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        }   
    }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        }   
    }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%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 int z; z for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        }   
    } ; {
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        }   
    } {
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        }   
    } if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        } y==0 y 0 {
                System.out.println(x);
                break; 
            } System.out.println(x) System.out.println System.out System System.out x break; {
                z=x;
                x=y;
                y=z%y;
        } z=x z x x=y x y y=z%y y z%y z 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();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%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();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%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();
        int z;
        for(;;){
            if(y==0){
                System.out.println(x);
                break; 
            }else{
                z=x;
                x=y;
                y=z%y;
        }   
    }
        sc.close();
    }
}
