#include <cstdlib>
#include <iostream>
int gcd(int x,int y);
using namespace std;
int main(void)
{
int a,b;
cin>>a>>b;
cout<<gcd(a,b)<<endl;
return 0;
}
int gcd(int x,int y)
{
if(x!=0&&y!=0)
{
return gcd((x>=y)?x%y:x,(x<y)?y%x:y);
}
else
{
return(x!=0)?x:y;
}
}