a, b = [int(tem) for tem in input().split()]

def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A

if a > b : print(mak(a, b))
else     : print(mak(b, a)) int(tem) for tem in input().split() for tem in input().split() tem input().split() ().split () input split for tem in input().split() int(tem) int tem a, b = [int(tem) for tem in input().split()] a [int(tem) for tem in input().split()] b def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A mak while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
     B != 0 B 0 q, r = divmod(A, B) q divmod(A, B) divmod A B r A = int((A - r) / q) A int((A - r) / q) int (A - r) / q A - r A r q B = r B r return A A A A B B if a > b : print(mak(a, b))
else     : print(mak(b, a)) a > b a b a, b = [int(tem) for tem in input().split()] [int(tem) for tem in input().split()] a b = [int(tem) for tem in input().split()] [int(tem) for tem in input().split()] b def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A mak
a, b = [int(tem) for tem in input().split()]

def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A

if a > b : print(mak(a, b))
else     : print(mak(b, a))