package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	var items []int
	for i := 0; i < n; i++ {
		item, _ := strconv.Atoi(nextLine())
		items = append(items, item)
	}
	ans := solve(n, items)
	fmt.Println(ans)
}

// Longest Increasing Subsequence
func solve(n int, items []int) int {
	l := len(items)
	dp := make([]int, 1, l)
	dp[0] = items[0]
	for i := 0; i < l; i++ {
		item := items[i]
		if dp[len(dp)-1] < item {
			dp = append(dp, item)
			continue
		}
		for j, d := range dp {
			if item < d {
				dp[j] = item
			}
		}
	}
	return len(dp)
}

