import numpy
l = input().split(' ')
N = int(l[0])
K = int(l[1])
A = []
for i in range(N):
  A.append(int(input()))

dp = [-1]*(N+1)
dp[0] = 0

for i in range(N):
  flg = False
  n = numpy.amax(dp)
  #print('a'+str(n))
  for j in range(n,-1,-1):
    arr = [k for k, x in enumerate(dp) if x == j]
    #print(arr)
    for k in range(len(arr)):
      if(abs(A[i]-A[arr[k]])<=K):
        dp[i] = dp[arr[k]]+1
        flg = True
        break
    if(flg):
      break

print(numpy.max(dp))