import Control.Monad
import Data.Array

lis xs = table
  where
    n = length xs
    bnds = (1, n)
    x = listArray bnds xs
    table = array bnds [(i, score i) | i <- range bnds]
    --
    score i = sc smallers
      where
        smallers = [j | j <- [1..i-1], x!j < x!i]
        sc [] = 1
        sc js = 1 + (maximum $ map (table!) js)

main = do
  n <- read <$>  getLine :: IO Int
  ps <- replicateM n $ read <$> getLine :: IO [Int]
  print $ solve n ps

solve n ps =
  ans
  where
    l = lis ps
    ans= n - (l!n) +1
    