#include<stdio.h>
int GCD(int,int);
int main(){
int input1,input2;
//while((scanf("%d%d",&input1,&input2))!=EOF){
scanf("%d%d",&input1,&input2);
printf("%d\n",GCD(input1,input2));
//}
return 0;
}
int GCD(int input1,int input2){
if(input1%input2==0){
return input2;
}
else{
return GCD(input2,input1%input2);
}
}