a,b = map(int,input().split())
s =[int(input())for i in range(a)]
w =[]
t =[]
cnt = 0
count = 0
for i in range(a):
    w.clear()
    w.append(s[i])
    for j in range(i+1,a):
        if abs(w[-1] - s[j]) <=b:
            count +=1
    if count > cnt:
        cnt = count
    count =0
print(cnt)

