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

B = [0] * len(A)
for b in range(len(B)):
  tmplist = []
  for idx, i in enumerate(range(b, len(A))):
    if idx == 0:
      tmp = A[i]
      tmplist.append(A[i])
      continue
    if abs(tmp - A[i]) <= K:
      tmplist.append(A[i])
      tmp = A[i]
  B.append(len(tmplist))
    

print(max(B))
