import Data.List (sort)
import qualified Data.Map as Map

main :: IO ()
main = print . solve . map read . tail . lines =<< getContents

solve :: [Int] -> Int
solve xs = let m = Map.fromList $ zip (sort xs) (cycle [0, 1])
               in length [ x | (i, x) <- zip (cycle [0, 1]) xs, maybe False (/=i) $ Map.lookup x m ] `div` 2
