#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a,b,r,A,B;
	cin>>a>>b;
	A=a;B=b;
	r=a%b;
	while(r!=0)
	{
		a=b; 
		b=r;
		r=a%b;
	}
	cout<<b<<endl;
    return 0;
}
