N, K = gets.split.map(&:to_i)
a_n = N.times.map{|_| gets.to_i}

ans = 0
h = Hash.new()
(0...N-1).each do |j|
  if !h[j].nil?
    next
  end
  a = a_n[j]
  h[j] = true
  tmp = 1
  ((j+1)...N).each do |i|
    if (a - a_n[i]).abs <= K
      tmp += 1
      a = a_n[i]
      h[i] = true
    end
  end
  ans = [tmp, ans].max
end
p ans