#include <bits/stdc++.h>
using namespace std;
unsigned long long a,b;
//chuongtrinhcon
unsigned long long ucln(long long a,long long b)
{
if (b==0) return(a);
else return(ucln(b,a%b));
}
//chuongtrinhchinh
int main()
{
freopen("vidu.inp","r",stdin);
freopen("vidu.out","w",stdout);
cin>>a>>b;
cout<<ucln(a,b);
return 0;
}