#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int m, n;
cin >> m >> n;
int t = 1;
for (int i = 1; i <= min(m, n); i++)
{
if (m % i == 0 && n % i == 0)
{
t = i;
}
}
cout << t;
return 0;
}