#include using namespace std; int GCD( const int X, const int Y ) { int s; int t; s = X; t = Y; while( true ) { s %= t; if( s == 0 ) return t; t %= s; if( t == 0 ) return s; } return 0; } int main() { int N; int M; cin >> N; cin >> M; cout << GCD( N, M ) << endl; return 0; }