#include <iostream>
using namespace std;
void maxCommonDivisor(int a,int b);int main ()
{ int a,b; cin >> a >> b ; maxCommonDivisor(a,b); return 0;}//运用辗转相除法
void maxCommonDivisor(int a,int b)
{ int t,c; if (a<b) { t=a; a=b; b=t; } c=a-b; if (a%c==0&&b%c==0) cout <<c << endl ; else { a=b; b=c; maxCommonDivisor(a,b); }}