def priority_push(array:, num:)
  index = array.bsearch_index { |i| i <= num}
  if index.nil?
    array.push(num)
  else
    array.insert(index, num)
  end
end

def priority_update(array:, index:, num:)
  array.delete_at(index)
  priority_push(array: array, num: num)
end

N = gets.to_i
arr = N.times.map{ gets.to_i }
stacks = [arr.shift]

arr.each do |i|
  overwrite_index = stacks.bsearch_index { |target| target < i }
  if overwrite_index.nil?
    stacks.push(i)
  else
    priority_update(array: stacks, index: overwrite_index, num: i)
  end
end
puts stacks.count
