
def gcd(x, y):

    if y > x:
        x, y = y, x

    if y == 0:
        return x

    if x >= y:
        return gcd(y, x % y)


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

    if y > x:
        x, y = y, x

    if y == 0:
        return x

    if x >= y:
        return gcd(y, x % y) gcd if y > x:
        x, y = y, x

     y > x y x x, y = y, x x y y x if y == 0:
        return x

     y == 0 y 0 return x x if x >= y:
        return gcd(y, x % y) x >= y x y return gcd(y, x % y) gcd(y, x % y) gcd y x % y x y x x y y int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i x, y = [int(i) for i in input().split()] x [int(i) for i in input().split()] y print(gcd(x, y)) print gcd(x, y) gcd x y x, y = [int(i) for i in input().split()] [int(i) for i in input().split()] x y = [int(i) for i in input().split()] [int(i) for i in input().split()] y def gcd(x, y):

    if y > x:
        x, y = y, x

    if y == 0:
        return x

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

    if y > x:
        x, y = y, x

    if y == 0:
        return x

    if x >= y:
        return gcd(y, x % y) gcd

def gcd(x, y):

    if y > x:
        x, y = y, x

    if y == 0:
        return x

    if x >= y:
        return gcd(y, x % y)


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