N, K = map(int,input().split())
A0 = int(input())
B = [[1,A0]]
for i in range(1,N):
    Ai = int(input())
    for j in range(len(B)):
        if abs(B[j][1] - Ai) <= K:
            B[j][0] += 1
            B[j][1] = Ai
    B.append([1,Ai])

ans = B[0][0]
for i in range(len(B)):
    ans = max(ans,B[i][0])

print(ans)