import Data.List
import Data.Tuple
--import Control.Monad
--import Control.Applicative
import GHC.Exts
    
main :: IO ()
main =
  fmap read getLine >>=
  \n -> fmap ((zipWith (,) [1..n]) . (map read) . words) getLine >>=
  \as -> putStrLn $ show $ solve as

solve :: [(Int,Int)] -> Int
solve as = sub (sortWith (fst) (map (\(x,y) -> if x <= y then (x,y) else (y,x)) as))

sub :: [(Int,Int)] -> Int
sub [] = 0
sub [a] = 0
sub (a1:[a2])
  | a1 == a2  = 1
  | otherwise = 0
sub (a1:a2:a3:as)
  | a1 == a2 = 1 + (sub (a3:as))
  | a2 == a3 = sub (a1:a3:as)
  | otherwise = sub (a2:as)