N = gets.chomp.to_i
arr = readlines.map{|n| n.chomp.to_i}
color = []
# p N,arr

arr.each do |n|
    index = color.bsearch_index {|x| x < n}
    if index.nil?
        color << n
    else
        color[index] = n
    end
    # p color
end
puts color.size
