n, m = map(int, input().split()) print(gcd(n, m))