N, K = map(int, input().split())
A = [int(input()) for i in range(N)]


ans = []

i = 0
while(i<=N-2):
  a = A[i]
  T = 1
  while (j<=N-1):
    if ( abs(a-A[j]) <= K ):
      T += 1
      a = A[j]
    j += 1
  ans.append(T)
  i += 1
  
print(max(ans))
