import math N, M = map(int, input().split()) print(math.gcd(N, M))