import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap.Strict as IM
import Data.Maybe (fromJust)
import Data.List (sort)

unsafeReadInt :: B.ByteString -> Int
unsafeReadInt = fst . fromJust . B.readInt

elemToIndex :: [Int] -> IM.IntMap Int
elemToIndex = IM.fromList . flip zip [0 ..]

minOps :: [Int] -> Int
minOps xs = length . filter f $ xs
    where
        raw = elemToIndex xs
        sorted = elemToIndex $ sort xs
        f i = odd (raw IM.! i) && even (sorted IM.! i)

main :: IO ()
main = B.getLine >>
    B.getContents >>= print . minOps . fmap unsafeReadInt . B.lines
