n = gets.to_i
input = []
n.times do
    input.push(gets.to_i)
end

result = [-1]
input.each do |val|
    added = false
    result.each.with_index do |r, i|
        if r < val
            result[i] = val
            added = true
            break
        end
    end
    if !added
        result.push(val)
    end
end
puts result.size