n,k=map(int,input().split())
arr=[]
for i in range(n):
  arr.append(int(input()))
 
dp=[0 for i in range(n)]
dp[0]=1
for i in range(1,n):
    
    for j in range(i):
        if abs(arr[j]-arr[i])<=k:
            dp[i]=max(dp[i],dp[j])
    dp[i]+=1
print(dp[n-1])
