n, k = gets.split.map(&:to_i)
a = Array.new(n){ gets.to_i }
max = 0
ans = []
n.times do |i|
  b = [a[i]]
  cnt = 0
  s = i
  i.next.upto(n.pred) do |j|
    if (a[s] - a[j]).abs <= k
      cnt += 1
      s = j
      b << a[j]
    end
  end
  if max < cnt
    max = cnt
    ans = Marshal.load(Marshal.dump(b))
  end
end

puts ans.size