# -*- coding: utf-8 -*-

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

D=[0]*N
S=[0]*N

A=int(input())
D[0]=1
S[0]=A

for i in range(1,N):
    A=int(input())
    for j in range(i):
        if abs(S[j]-A)<=K:
            D[j]+=1
            S[j]=A
    D[i]=1
    S[i]=A

ans=max(D)
print(ans)



