N, K = map(int, input().split())

A = [int(input()) for i in range(N)]

memo = {}


def solve(n, v):
    if (n, v) in memo:
        return memo[(n, v)]
    if n == N - 1:
        if abs(v - A[n]) <= K:
            return 1
        else:
            return 0

    else:
        if abs(v - A[n]) <= K:
            res = max([solve(n + 1, A[n]) + 1, solve(n + 1, v)])
            memo[(n, v)] = res
            return res
        else:
            res = solve(n + 1, v)
            memo[(n, v)] = res
            return res


print(solve(0, A[0]))