n,k=map(int,input().split())
a=[]
for i in range(n):
    ai=int(input())
    a.append(ai)

def rec(x):
    ans=1     
    for i in range(x+1,n):
        if abs(a[i]-a[x])<=k:
            ans=max(rec(i)+1,ans)    
    return ans

print(rec(0))