def METHOD_NAME(a, b, tol=1e-9):
    n = 0
    while True:
        ma = a.moment(n)
        mb = b.moment(n)
        dif = (ma - mb) / np.mean(np.absolute(0.5 * (ma + mb)))
        err = np.linalg.norm(dif)
        if err < tol:
            n += 1
        else:
            break
    return n