
{-# LANGUAGE MultiWayIf #-}

import Data.Array (accumArray, assocs)
import Data.List (foldl', sortOn)

a#b = abs (a-b)

freq = filter ((>0).snd) . assocs . accumArray (+) 0 (1,100000) . flip zip (repeat 1)

split :: [a] -> ([a] -> [a] -> c) -> c
split [] c = c [] []
split (o:e:xs) c = split xs (\os es -> c (o:os) (e:es))

solv :: Int -> [Int] -> [Int] -> Int
solv n xs ys = case (xfreq, yfreq) of
    ([(o1,_)], [(e1,_)])
      | o1/=e1 -> 0
      | o1==e1 -> div n 2
    ([(o1,_)], ((e1,c1):(e2,c2):_))
      | o1/=e1 -> (div n 2)-c1
      | o1==e1 -> (div n 2)-c2
    (((o1,c1):(o2,c2):_), [(e1,_)])
      | o1/=e1 -> (div n 2)-c1
      | o1==e1 -> (div n 2)-c2
    (((o1,co1):(o2,co2):_), ((e1,ce1):(e2,ce2):_))
      | o1/=e1 -> n-(co1+ce1)
      | o1==e1 -> n- (max (co1+ce2) (co2+ce1))
  where
    xfreq = reverse.sortOn snd.freq $ xs
    yfreq = reverse.sortOn snd.freq $ ys

main = do
  n <- read <$> getLine
  xs <- map read . words <$> getLine :: IO [Int]
  let (os,es) = split xs $ flip (,)
  print $ solv n os es
