n,k=map(int,input().split())
a = [int(input()) for i in range(n)]
anslist=[1]*n
checklist=[]
for j in range(n):
    for l in range(j+1,n):
        if abs(a[j]-a[l])<=k:
            checklist.append([j,l])
            break


for m in checklist:
    if anslist[m[0]]>=anslist[m[1]]:
        anslist[m[1]]+=anslist[m[0]]

print(max(anslist))