#include<iostream>
using namespace std;
int main()//用减法求最大公约数
{
int a,b,c;
cin>>a>>b;
{
if(a>b)
a=a-b;
else
b=b-a;
}
cout<<a<<endl;
return 0;
}
using namespace std;
int main()//用减法求最大公约数
{
int a,b,c;
cin>>a>>b;
/*1.当a==b时 a(或者b)为最大公约数*/
/*2.当a!=b时 用大数减小数 取得的差赋值给大数然后循环1.2步骤*/
while(a!=b){
if(a>b)
a=a-b;
else
b=b-a;
}
cout<<a<<endl;
return 0;
}