n,k = map(int,input().split())
a = [int(input()) for _ in range(n)]

dp = [0]*n

for j in range(n):
  b = a[j]
  for i in range(n-1):
    if abs(b-a[i+1]) <= k:
      dp[i+1] = max(dp[i]+1,dp[i+1])
      b = a[i+1]
    else:
      dp[i+1] = dp[i]
      
print(max(dp))