X= input().split()
N = int(X[0])
K = int(X[1])
A = list()
ANS = list()
for i in range(N):
  Y = input()
  A.append(int(Y))
for i in range(N):
  B = list()
  for Z in range(i, N):
    if Z == i:
      B.append(A[Z])
    else:
      if abs(A[Z-1]-A[Z])<=K:
        B.append(A[Z])
  ANS.append(len(B))
print(max(ANS))