#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int gcd(int a,int b)
{
if(a%b==0)
return b;
return gcd(b,a%b);
}
int main()
{
int a,b;
int i;
cin>>a>>b;
if(a<b)
cout<<gcd(b,a);
else
cout<<gcd(a,b);
return 0;
}