N,K = map(int, input().split())
an_max = 1
li = []

for t  in range(N):
    li.append(int(input()))

for t in range(N):
 a = li[t]
 an = 1

 for i in range(t+1,N):
    x = li[i]

    if abs(a - x) <= K:
        an += 1
        a = x

 if an_max < an:
     an_max = an

print(an_max)