#include<iostream>
using namespace std;
int gcd(int a, int b)
{
for(int i = a;i;i --)
if(a % i == 0 && b % i == 0)
return i;
}
int main()
{
int a, b;
cin >> a >> b;
if(a > b) swap(a, b);
cout << gcd(a, b) << endl;
return 0;
}