n,k=map(int,input().split())
visited=[0]*n
li=[int(input()) for i in range(n)]
ans=0
for i in range(n):
    if visited[i]==0: #まだ訪れていない場合
        cnt=1
        x=li[i]
        t=[li[i]]
        for j in range(i+1,n):
            if abs(x-li[j])<=k:
                cnt+=1
                x=li[j]
                visited[j]=1
                t+=[li[j]]
        ans=max(cnt,ans)
print(ans)