res = []
min = Float::MAX.to_i

gets.to_i.times do
  v = gets.to_i
  ok = false

  if v > min
    res.each_with_index do |r, i|
      next if r >= v

      res[i] = v
      ok = true
      break
    end
  end

  unless ok
    res << v
    min = v if v < min
  end
end

puts res.size
