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