n = gets.to_i

as = []
n.times{
	as << gets.to_i
}

branch = []

as.each{ |x|
	isExists = false

	index = branch.bsearch_index{ |y| y < x }

	if index then
		branch[index] = x
	else
		branch << x
	end
}

puts branch.size
