#include <iostream>
using namespace std;
int GCD(int a, int b){
if (b == 0) return a;
else return GCD(b, a % b);
}
int main() {
int a, b;
cin >> a >> b;
cout << GCD(a,b);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgR0NEKGludCBhLCBpbnQgYil7CiAgaWYgKGIgPT0gMCkgcmV0dXJuIGE7CiAgZWxzZSByZXR1cm4gR0NEKGIsIGEgJSBiKTsKfQoKaW50IG1haW4oKSB7CiAgICBpbnQgYSwgYjsKICAgIGNpbiA+PiBhID4+IGI7CiAgICBjb3V0IDw8IEdDRChhLGIpOwogIHJldHVybiAwOwp9