动态规划
#  5 4 6 7 1
arr = list(map(int, input().split()))
dp = [1] * len(arr)
for i in range(1, len(arr)):
    if min(arr[0: i]) < arr[i]:
        for j in range(i):
            if arr[j] < arr[i] and dp[j] >= dp[i] - 1:
                dp[i] = dp[j] + 1
print(max(dp))