N, K = map(int, input().split())
A = list(int(input()) for _ in range(N))

ans = 0
for i, a in enumerate(A):
    tmp = [0] * (N + 1)
    for j in range(i, N):
        tmp[j + 1] = tmp[j]
        if abs(A[j] - A[j - 1]) <= K:
            tmp[j + 1] += 1
    if tmp[-1] > ans:
        ans = tmp[-1]
    if N - (i + 1) <= ans:
        break

print(ans)
