import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc [] k = k
calc (z : zs) k
  | (snd z, fst z) `elem` zs = calc zs (k + 1)
  | otherwise = calc zs k

main = do
  n <- getInt
  as <- getIntList
  let zs = zip as [1 .. (length as)]
  print $ calc zs 0
