N,K=map(int,input().split())
ans=0
inf=10**6
temp=[[]]
a=int(input())
temp[0].append(a)
flag=True

for i in range(1,N):
    a=int(input())
    for s in temp:
        if abs(s[-1]-a)<=K:
            s.append(a)
            flag=False
    if flag:
        temp.append([a])
        flag=True


for s in temp:
    ans=max(ans,len(s))

print(ans)