def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

x, y = [int(n) for n in input().split()]
print(gcd(x, y)) def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) gcd if y == 0:
        return x
    else:
        return gcd(y, x % y) 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 int(n) for n in input().split() for n in input().split() n input().split() ().split () input split for n in input().split() int(n) int n x, y = [int(n) for n in input().split()] x [int(n) for n in input().split()] y print(gcd(x, y)) print gcd(x, y) gcd x y x, y = [int(n) for n in input().split()] [int(n) for n in input().split()] x y = [int(n) for n in input().split()] [int(n) for n in input().split()] y def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) gcd
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

x, y = [int(n) for n in input().split()]
print(gcd(x, y))