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