def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n


a,b = map(int,input().split())
gcd(a,b) def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n gcd x = max(a,b) x max(a,b) max a b y = min(a,b) y min(a,b) min a b while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n True n = x%y n x%y x y if n == 0:
            print(y)
            break
        else:
            x = y
            y = n n == 0 n 0 print(y) print y break x = y x y y = n y n a a b b a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b gcd(a,b) gcd a b a,b = map(int,input().split()) map(int,input().split()) a b = map(int,input().split()) map(int,input().split()) b def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n gcd
def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while True:
        n = x%y
        if n == 0:
            print(y)
            break
        else:
            x = y
            y = n


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