def gcd(a,b):
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b

a,b = list(map(int,input().split()))
print (gcd(a,b)) def gcd(a,b):
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b gcd r = a % b r a % b a b while r != 0:
        a, b = b, r
        r = a % b
     r != 0 r 0 a, b = b, r a b b r r = a % b r a % b a b return b b a a b b a,b = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split b print (gcd(a,b)) print gcd(a,b) gcd a b a,b = list(map(int,input().split())) list(map(int,input().split())) a def gcd(a,b):
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b def gcd(a,b):
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b gcd b = list(map(int,input().split())) list(map(int,input().split())) b
def gcd(a,b):
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b
    return b

a,b = list(map(int,input().split()))
print (gcd(a,b))