#include int gcd(int a, int b) { int d, r; if ((a == b) || (a == 0)) return a; if (b == 0) return b; if (b > a) { d = a; a = b; b = d; } for(;;) { d = a / b; r = a - (d * b); if (r == 0) break; a = b; b = r; } return b; } int main() { int a, b; std::cin >> a >> b; std::cout << gcd(a, b) << std::endl; return 0; }