def ngcd(x, y):
    x = abs(int(x))
    y = abs(int(y))
    if x == 0 and y == 0:
        return 0
    while y:
        x, y = y, x % y
    return x