def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y

if __name__ == '__main__':
    x, y = map(int, input().split())
    gcd = greatest_common_divisor(x, y)
    print(gcd)
 def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y greatest_common_divisor while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

     True if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

     x == 0 or y == 0 x == 0 x 0 y == 0 y 0 break elif x >= y:
            x %= y
         x >= y x y x %= y x y y %= x y x return x+y x+y x y x x y y if __name__ == '__main__':
    x, y = map(int, input().split())
    gcd = greatest_common_divisor(x, y)
    print(gcd) __name__ == '__main__' __name__ '__main__' x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y gcd = greatest_common_divisor(x, y) gcd greatest_common_divisor(x, y) greatest_common_divisor x y print(gcd) print gcd def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y greatest_common_divisor y = map(int, input().split()) map(int, input().split()) y gcd = greatest_common_divisor(x, y) greatest_common_divisor(x, y) gcd x, y = map(int, input().split()) map(int, input().split()) x
def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y

if __name__ == '__main__':
    x, y = map(int, input().split())
    gcd = greatest_common_divisor(x, y)
    print(gcd)

