#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, m;
cin >> x >> y;
if (x < y) swap(x, y);
while( y !=0){
m = x % y;
x = y;
y = m;
}
cout << x;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB4LCB5LCBtOwoJY2luID4+IHggPj4geTsKCWlmICh4IDwgeSkgc3dhcCh4LCB5KTsKCXdoaWxlKCB5ICE9MCl7CgkJbSA9IHggJSB5OwoJCXggPSB5OwoJCXkgPSBtOwoJfQoJY291dCA8PCB4OwoJcmV0dXJuIDA7Cn0=