def euclid(a, b):
    while a != 0 and b != 0:
        if a > b:
            a = a % b
        else:
            b = b % a
    return (a+b)
a, b = input().split(' ')
a = int(a)
b = int(b)
print (euclid(a, b))


ed99753776706d9a498f59ae08cb3964ff289be2
<mask token>

def euclid(a, b):
    while a != 0 and b != 0:
        if a > b:
            a = a % b
        else:
            b = b % a
    return a + b


<mask token>

def euclid(a, b):
    while a != 0 and b != 0:
        if a > b:
            a = a % b
        else:
            b = b % a
    return a + b


<mask token>
print(euclid(a, b))

def euclid(a, b):
    while a != 0 and b != 0:
        if a > b:
            a = a % b
        else:
            b = b % a
    return a + b


a, b = input().split(' ')
a = int(a)
b = int(b)
print(euclid(a, b))

def euclid(a, b):
    while a != 0 and b != 0:
        if a > b:
            a = a % b
        else:
            b = b % a
    return (a+b)
a, b = input().split(' ')
a = int(a)
b = int(b)
print (euclid(a, b))

