def swap(x, y):
    tmp = x
    x = y
    y = tmp

def gcm(x, y):
    if x < y:
        swap(x, y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

if __name__ == '__main__':
    x, y = list(map(int, input().split()))
    n = gcm(x, y)
    print(n) def swap(x, y):
    tmp = x
    x = y
    y = tmp swap tmp = x tmp x x = y x y y = tmp y tmp x x y y def gcm(x, y):
    if x < y:
        swap(x, y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x gcm if x < y:
        swap(x, y)
     x < y x y swap(x, y) swap x y while y > 0:
        r = x % y
        x = y
        y = r
     y > 0 y 0 r = x % y r x % y x y x = y x y y = r y r return x x x x y y if __name__ == '__main__':
    x, y = list(map(int, input().split()))
    n = gcm(x, y)
    print(n) __name__ == '__main__' __name__ '__main__' 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 n = gcm(x, y) n gcm(x, y) gcm x y print(n) print n x, y = list(map(int, input().split())) list(map(int, input().split())) x def gcm(x, y):
    if x < y:
        swap(x, y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x def gcm(x, y):
    if x < y:
        swap(x, y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x gcm def swap(x, y):
    tmp = x
    x = y
    y = tmp def swap(x, y):
    tmp = x
    x = y
    y = tmp swap y = list(map(int, input().split())) list(map(int, input().split())) y n = gcm(x, y) gcm(x, y) n
def swap(x, y):
    tmp = x
    x = y
    y = tmp

def gcm(x, y):
    if x < y:
        swap(x, y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

if __name__ == '__main__':
    x, y = list(map(int, input().split()))
    n = gcm(x, y)
    print(n)