#include using namespace std; typedef long long ll; typedef vector VI; typedef vector VVI; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define FOR(i, f, t) for(int(i)=(f);(i)<(t);(++i)) const int MOD = int(1e9+7); ll gcd(ll n, ll m){return m?gcd(m,n%m):n;} int main(){ int N, M; cin >> N >> M; cout << gcd(N,M) << endl; return 0; }