def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y != 0:
        x, y = y, x % y
    return x

X, Y = (int(s) for s in input().split())
print(gcd(X, Y)) def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y != 0:
        x, y = y, x % y
    return x gcd x, y = max(x, y), min(x, y) x max(x, y) max x y y min(x, y) min x y while y != 0:
        x, y = y, x % y
     y != 0 y 0 x, y = y, x % y x y y x % y x y return x x x x y y int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s X, Y = (int(s) for s in input().split()) X (int(s) for s in input().split()) Y print(gcd(X, Y)) print gcd(X, Y) gcd X Y X, Y = (int(s) for s in input().split()) (int(s) for s in input().split()) X def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y != 0:
        x, y = y, x % y
    return x def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y != 0:
        x, y = y, x % y
    return x gcd Y = (int(s) for s in input().split()) (int(s) for s in input().split()) Y
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while y != 0:
        x, y = y, x % y
    return x

X, Y = (int(s) for s in input().split())
print(gcd(X, Y))