#include <iostream>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
if (a<b){
while (a!=b)
b=b-a;
cout <<b;
}
if (a<b){
while (a!=b)
a=a-b;
cout <<a;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpewppbnQgYSxiOwpjaW4gPj5hPj5iOwppZiAoYTxiKXsKd2hpbGUgKGEhPWIpCmI9Yi1hOwpjb3V0IDw8YjsKfQppZiAoYTxiKXsKd2hpbGUgKGEhPWIpCmE9YS1iOwpjb3V0IDw8YTsKfQoJcmV0dXJuIDA7Cn0=