#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
        if(a<0||b<0){
            printf("Invalid input");
        }
        while(b!=0){
            int max=a;
            a=b;
            b=max;
        }
        printf("%d",b);

}