#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,r;
	r=1; 
    cin>>m>>n;
    while(r){ 
    r=m%n;    
	  m=n;
        n=r;
}
    cout<<m;

    return 0;
    }   

/**************************************************************
	Problem: 1088
	User: LYY001
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/