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

dp = [0] * (N+1)
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] > dp[-1]:
        dp = tmp

print(dp[-1])