n, k = map(int,input().split())
l = [[int(input())]]
l_size = [1]
for i in range(n-1):
  a = int(input())
  max_size = 1
  max_tmp = [a]
  for j, item in enumerate(l):
    sa = item[-1] - a
    if sa <0:sa = -sa
    if sa <=k:
      tmp = item + [a]
      tmp_size = l_size[j]+1
      if max_size < tmp_size:
        max_size = tmp_size
        max_tmp = tmp
  l.append(max_tmp)
  l_size.append(max_size)
#  print(l)
  
ans = max(l_size)
print(ans)