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


x, y = list(map(int, input().split()))

print(gcm(x, y)) def gcm(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
    if x==y:
        return x
    if x>y:
        return gcm(x%y,y)
    else:
        return gcm(y%x,x) gcm if x == 0:
        return y
     x == 0 x 0 return y y if y == 0:
        return x
     y == 0 y 0 return x x if x==y:
        return x
     x==y x y return x x if x>y:
        return gcm(x%y,y)
    else:
        return gcm(y%x,x) x>y x y return gcm(x%y,y) gcm(x%y,y) gcm x%y x y y return gcm(y%x,x) gcm(y%x,x) gcm y%x y x x x x y y x, y = list(map(int, input().split())) x list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split y print(gcm(x, y)) print gcm(x, y) gcm x y def gcm(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
    if x==y:
        return x
    if x>y:
        return gcm(x%y,y)
    else:
        return gcm(y%x,x) def gcm(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
    if x==y:
        return x
    if x>y:
        return gcm(x%y,y)
    else:
        return gcm(y%x,x) gcm x, y = list(map(int, input().split())) list(map(int, input().split())) x y = list(map(int, input().split())) list(map(int, input().split())) y
def gcm(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
    if x==y:
        return x
    if x>y:
        return gcm(x%y,y)
    else:
        return gcm(y%x,x)


x, y = list(map(int, input().split()))

print(gcm(x, y))
