#include<iostream>
using namespace std;
int main()
{
int x,y,temp,ans;
cin>>x>>y;//28 7
if( x<y)
{
temp=x;
x=y;
y=temp;
}
while( x != y)//28 7
{
x-=y;//21
if( x<y)
{
temp=x;
x=y;
y=temp;
}
}
ans=x;
cout<<ans<<endl;
return 0;
}
/*
输入:28 7
输出:__________
*/