import Data.Functor
import Control.Applicative
import Control.Monad
import qualified Data.IntSet as IS
import Data.List
import qualified Data.ByteString.Char8 as C
import Data.Maybe

main = sol <$> (C.getLine *> get) >>= print

get = fmap fst . mapMaybe C.readInt . C.lines <$> C.getContents

sol = IS.size . foldl' lis IS.empty

lis s a = case IS.lookupGE a s of
    Just x
        | a < x         -> IS.insert a $ IS.delete x s
        | otherwise     -> s
    Nothing             -> IS.insert a s