N,K=map(int,input().split())
ans=0

a=int(input())
temp=[a]
inf=10**6
lenss=[0]*inf
lenss[0]+=1
flag=True

for i in range(1,N):
    a=int(input())
    for i in range(len(temp)):
        if abs(temp[i]-a)<=K:
            temp[i]=a
            lenss[i]+=1
            ans=max(ans,lenss[i])
            flag=False
    if flag:
        temp.append(a)
        flag=True
    flag=True

print(ans)
