#include <iostream>
using namespace std;
int main() {
int x, y, m;
cin >> x >> y;
while( y !=0){
m = x % y;
x = y;
y = m;
}
cout << x;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgeCwgeSwgbTsKCWNpbiA+PiB4ID4+IHk7Cgl3aGlsZSggeSAhPTApewoJCW0gPSB4ICUgeTsKCQl4ID0geTsKCQl5ID0gbTsKCX0KCWNvdXQgPDwgeDsKCQoJcmV0dXJuIDA7Cn0=