N,K=map(int,input().split())
ans=[1]
A_old=[int(input())]
for _ in range(N-1):
    A_new=int(input())
    for i in range(len(A_old)):
        if abs(A_new-A_old[i])<=K:
            ans[i]+=1
            A_old[i]=A_new
        else:
            A_old.append(A_new)
            ans.append(1)

ans=max(ans)
if ans==1:
    ans=0
print(ans)