import sys

def solve():
    A = list(map(int, sys.stdin.readlines()))
    n = A[0]
    A[0] = -1
    L = [0] * (n + 1)
    for i, a_i in enumerate(A[1:], start=1):
        k = 0
        for j, a_j in enumerate(A[:i]):
            if a_j < a_i and L[j] > L[k]:
                k = j
        L[i] = L[k] + 1
    print(max(L))

solve()