import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec
import Debug.Trace as De

--getIntList = map read . words <$> getLine


listToTriple abc =(a,b,c)
    where [a,b,c]=abc
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c

solve str=sum (map (\(a,b)-> if(a>b) then 1 else 0 ) (zip str ssr)  )
    where ssr=sort(str)

main = do
    n <-getLine
    str <- getLine
    putStrLn(show (solve str))



    

