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

dp = [[[0, -1], [0, -1]] for _ in range(n)] 
dp[0][1] = [1, A[0]]

# print(dp)

for i in range(1, n):
  for j in range(2):
    for p in range(2):
      if j == 1 and (dp[i-1][p][1] == -1 or abs(A[i] - dp[i-1][p][1]) <= k) and (dp[i][j][0] <= dp[i - 1][p][0] + 1):
        dp[i][j][0] = dp[i - 1][p][0] + 1
        dp[i][j][1] = A[i]
      else:
        if dp[i][j][0] <= dp[i - 1][p][0]:
          dp[i][j][1] = dp[i - 1][p][1]
          dp[i][j][0] = dp[i - 1][p][0]
          
ans = 0
for i in range(2):
  ans = max(ans, dp[-1][i][0])
  
print(ans)
