N,K = map(int,input().split())
ans,n = 1,1
dp = [1]*N
As = [0]*N
for i in range(N):
  As[i] = Ai = int(input())
  for j,Aj in enumerate(As[max(0,i-100):i]):
    if abs(Ai-Aj)<=K: dp[i] = max(dp[i],dp[j]+1)
print(dp[-1])