def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if y == 0:
        return x
    return gcd(y, x % y)
x, y = map(int, input().split())
print(gcd(x, y)) def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if y == 0:
        return x
    return gcd(y, x % y) gcd if x < y:
        return gcd(y, x)
     x < y x y return gcd(y, x) gcd(y, x) gcd y x if y == 0:
        return x
     y == 0 y 0 return x x return gcd(y, x % y) gcd(y, x % y) gcd y x % y x y x x y y x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y print(gcd(x, y)) print gcd(x, y) gcd x y y = map(int, input().split()) map(int, input().split()) y def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if y == 0:
        return x
    return gcd(y, x % y) def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if y == 0:
        return x
    return gcd(y, x % y) gcd x, y = map(int, input().split()) map(int, input().split()) x
def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if y == 0:
        return x
    return gcd(y, x % y)
x, y = map(int, input().split())
print(gcd(x, y))
