N, K = map(int, input().split())
A = [input() for i in range(N)]
ans = [1] * N

for j in range(N):
    if max(ans) >= N - j:
        break
    before = j
    after = j + 1
    while after < N:
        if abs(int(A[after]) - int(A[before])) <= K:
            ans[j] += 1
            before = after
            after = before +  1
        else:
            after += 1
    
print(max(ans))