CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
V = list(map(int, input().split()))
A = V[::2]
B = V[1::2]
set_A = set(A)
set_B = set(B)
max_a = 0
max_b = 0

for a in set_A:
  cnt_a = A.count(a)
  max_a = max(max_a, cnt_a)
for b in set_B:
  cnt_b = B.count(b)
  max_b = max(max_b, cnt_b)
ans = (len(A) - max_a) + (len(B) - max_b)
if ans == 0 and A[0] == B[0]:
  ans = n // 2
print(ans)

# Optimized solution
n = int(eval(input()))
V = list(map(int, input().split()))
A = {}
B = {}
for i in range(n):
  if i % 2 == 0:#A
    A[V[i]] = A.get(V[i], 0) + 1
  else:#B
    B[V[i]] = B.get(V[i], 0) + 1

A = sorted(list(A.items()), key=lambda x:x[1], reverse=True)
B = sorted(list(B.items()), key=lambda x:x[1], reverse=True)
a1, b1 = A[0][1], B[0][1]
am, bm = A[0][0], B[0][0]
ans = n - a1 - b1
if ans == 0 and V[0]==V[1]:
  ans = n//2
elif am == bm and n > 4:
  a2,b2 = A[1][1], B[1][1]
  ans = min(n - a2 - b1, n - a1 - b2) 
print(ans)
# Original solution
n = int(eval(input()))
l = list(input().split())
ll,lr = l[::2],l[1::2]
dl,dr = {},{}
for i in ll: dl[i] = dl.get(i,0)+1
for j in lr: dr[j] = dr.get(j,0)+1
ltl = sorted(list(dl.items()),key=lambda k:-k[1])
ltr = sorted(list(dr.items()),key=lambda k:-k[1])
if ltl[0][0] != ltr[0][0]:
  print((n-ltl[0][1]-ltr[0][1]))
elif len(ltl)<2:
  print((n//2))
else:
  print((n-ltl[0][1]-max(ltl[1][1],ltr[1][1])))

# Optimized solution
n = int(eval(input()))
v = list(input().split())
def f(b):
  h = v[b::2]
  d = {0:0}
  for i in h: d[i] = d.get(i,0)+1
  return sorted(list(d.items()),key=lambda k:-k[1])
l,r = f(0),f(1)
print((n-l[0][1]-[r[0][1],max(l[1][1],r[1][1])][l[0][0] == r[0][0]]))
# Original solution
from collections import Counter
n = int(eval(input()))
v = list(map(int, input().split()))
gu = v[::2]
ki = v[1::2]
ans = 0
k,g = False,False

if v.count(v[0]) == n:#全部同じ
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            k = True
        else:
            g = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if g:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if k:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)

# Optimized solution
from collections import Counter
n = int(eval(input()))
v = list(map(int, input().split()))
gu = v[::2]
ki = v[1::2]
ans = 0
k,g = False,False

###全部同じなら全長の半分,
# 最頻値が同じなら2番目を比べる
if v.count(v[0]) == n:
    ans += n // 2
else:
    kic = Counter(ki)
    guc = Counter(gu)
    k1 = kic.most_common(2)
    g1 = guc.most_common(2)
    if k1[0][0] == g1[0][0]:
        if k1[1][1] < g1[1][1]:
            g = True
        else:
            k = True

    kic = list(kic.values())
    guc = list(guc.values())
    kic.sort(reverse = True)
    guc.sort(reverse = True)
    if len(kic) != 1:
        if k:
            ans += kic[0]
            ans += sum(kic[2::])
        else:
            ans += sum(kic[1::]) 
    if len(guc) != 1:
        if g:
            ans += guc[0]
            ans += sum(guc[2::])
        else:
            ans += sum(guc[1::])

print(ans)
# Original solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
vvv = na()
d = {}
for i in range(n):
    if vvv[i] not in list(d.keys()):
        d[vvv[i]] = 1
    else:
        d[vvv[i]] += 1
if len(list(d.keys())) == 1:
    print((n // 2))
else:
    num1 = max(d, key=d.get)
    d.pop(num1)
    num2 = max(d, key=d.get)
    ct1 = 0
    ct2 = 0
    now1 = num1
    now2 = num2
    for i in range(n):
        if vvv[i] != now1:
            ct1 += 1
        if vvv[i] != now2:
            ct2 += 1
        now1, now2 = now2, now1
    print((min(ct1, ct2)))

# Optimized solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
vvv = na()
even = vvv[::2]
odd = vvv[1::2]
d_even = {}
d_odd = {}
for i in range(n//2):
    if even[i] not in list(d_even.keys()):
        d_even[even[i]] = 1
    else:
        d_even[even[i]] += 1

    if odd[i] not in list(d_odd.keys()):
        d_odd[odd[i]] = 1
    else:
        d_odd[odd[i]] += 1

e_max = max(d_even, key=d_even.get)
o_max = max(d_odd, key=d_odd.get)
e1 = d_even[e_max]
o1 = d_odd[o_max]

if e_max == o_max:
    d_even[e_max] = 0
    d_odd[o_max] = 0

    e2 = max(d_even.values())
    o2 = max(d_odd.values())

    ans = n - max(e1 + o2, e2 + o1)

else:
    ans = n - e1 - o1

print(ans)
# Original solution
from collections import Counter
n = int(eval(input()))
v = list(map(int ,input().split()))

o = Counter(v[::2]).most_common() # 偶数列の最頻値の順に並べる
e = Counter(v[1::2]).most_common() # 奇数列の最頻値の順に並べる

if o[0][0] == e[0][0]: # 最頻値が偶数列と奇数列で同じかどうか判定
  if len(o) == 1: print((n//2)) # 値のバリエーションが最頻値のみの場合は片方の数列を書き換えて終わり
  else:
    # 最終的に数列上に残る値の種類は2種類のみの為、上位2種の値へ全て揃える
    # 下記の2パターンで書き換える数が少ない方が回答になる
    o1,o2 = e[0][1], e[1][1]
    e1,e2 = o[0][1], o[1][1]
    
    ans = min(n-e1-o2, n-e2-o1)
    print(ans)
else:
  print((n - o[0][1] - e[0][1])) #最頻値が異なる場合は、全体の数からそれぞれの最頻値の数を引く

# Optimized solution
from collections import Counter
n = int(eval(input()))
v = list(map(int, input().split()))

o = Counter(v[::2]).most_common()
e = Counter(v[1::2]).most_common()
if o[0][0] == e[0][0]:
  if len(o) == 1: print((e[0][1]))
  else:
    o1,o2 = e[0][1], e[1][1]
    e1,e2 = o[0][1], o[1][1]
  
    ans = min(n-o1-o2, n-e1-e2)
    print(ans)
else: print((n-o[0][1]-e[0][1]))
# Original solution
from collections import Counter
n = int(eval(input()))
lis = list(map(int, input().split()))

a = Counter(lis[::2])
b = Counter(lis[1::2])

aa = sorted(list(a.items()), key=lambda x:x[1], reverse=True)
bb = sorted(list(b.items()), key=lambda x:x[1], reverse=True)

if aa[0][0] == bb[0][0]:
    if len(aa) > 1 and len(bb) > 1:
        res = n - max(aa[0][1]+bb[1][1], aa[1][1]+bb[0][1])
    elif len(aa) == 1 and len(bb) > 1:
        res = n - aa[0][1] - bb[1][1]
    elif len(aa) > 1 and len(bb) == 1:
        res = n - aa[1][1] - bb[0][1]
    else:
        res = n - aa[0][1]
else:
    res = n - aa[0][1] - bb[0][1]

print(res)


# Optimized solution
from collections import Counter
n = int(eval(input()))
lis = list(map(int, input().split()))

a = Counter(lis[::2])
b = Counter(lis[1::2])

aa = sorted(list(a.items()), key=lambda x:x[1], reverse=True)
bb = sorted(list(b.items()), key=lambda x:x[1], reverse=True)

aa.append((0, 0))
bb.append((0, 0))

if aa[0][0] == bb[0][0]:
    res = n - max(aa[0][1]+bb[1][1], aa[1][1]+bb[0][1])
else:
    res = n - aa[0][1] - bb[0][1]
print(res)
# Original solution
from collections import Counter
n = int(eval(input()))
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
count1 = Counter(v1)
count2 = Counter(v2)
count1[0] = 0
MAX = 0
for i in list(count1.keys()):
    for j in list(count2.keys()):
        if i != j and MAX < count1[i] + count2[j]:
            MAX = count1[i] + count2[j]
print((n - MAX))

# Optimized solution
from collections import Counter
n = int(eval(input()))
v = list(map(int,input().split()))
v1 = v[0::2]
v2 = v[1::2]
count1 = Counter(v1)
count2 = Counter(v2)
count1[0] = 0
count2[0] = 0
items1 = []
items2 = []
key1 = max(list(count1.keys()), key = count1.get)
items1.append([key1, count1[key1]])
del count1[key1]
key1 = max(list(count1.keys()), key = count1.get)
items1.append([key1, count1[key1]])

key2 = max(list(count2.keys()), key = count2.get)
items2.append([key2, count2[key2]])
del count2[key2]
key2 = max(list(count2.keys()), key = count2.get)
items2.append([key2, count2[key2]])

if items1[0][0] != items2[0][0]:
    m = items1[0][1] + items2[0][1]
else:
    m = max(items1[0][1] + items2[1][1], items1[1][1] + items2[0][1])
print((n - m))
# Original solution
#!/usr/bin/env python3
#ABC111 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
v = LI()
s,t = [],[]
for i in range(n):
    if i % 2:
        t.append(v[i])
    else:
        s.append(v[i])
s = list(Counter(s).items())
s.sort(key = itemgetter(1),reverse = True)
t = list(Counter(t).items())
t.sort(key = itemgetter(1),reverse = True)
m = min(len(s),len(t))
for i in range(m):
    a,b = s[i]
    c,d = t[i]
    if a != c:
        print(((n//2 - b)+(n//2 - d)))
        quit()
    elif a == c:
        if i + 1 < len(s) - 1:
            tmp1 = s[i+1][1]
        else:
            tmp1 = 0
        if i + 1 < len(t) - 1:
            tmp2 = t[i+1][1]
        else:
            tmp2 = 0
        print((min(((n//2 - b) + (n//2 - tmp2),((n//2 - d) + (n//2 - tmp1))))))
        quit()


# Optimized solution
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
v = LI()
a = []
b = []
for i in range(n):
    if i % 2 == 0:
        a.append(v[i])
    else:
        b.append(v[i])
a = list(Counter(a).items())
b = list(Counter(b).items())
a.sort(key = lambda x:x[1], reverse=1)
b.sort(key = lambda x:x[1], reverse=1)
if len(a) == 1 and len(b) == 1:
    if a[0][0] == b[0][0]:
        print((n//2))
    else:
        print((0))
elif len(a) > 1 and len(b) == 1:
    if a[0][0] == b[0][0]:
        print(((n-1)//2 + 1 - a[1][1]))
    else:
        print(((n-1)//2 + 1 - a[0][1]))
elif len(a) == 1 and len(b) > 1:
    if a[0][0] == b[0][0]:
        print((n//2 - b[1][1]))
    else:
        print((n//2 - b[0][1]))
else:
    if a[0][0] == b[0][0]:
        print((min((n-1)//2 + 1 - a[1][1] + (n // 2) - b[0][1], (n-1)//2 + 1 - a[0][1] + (n // 2) - b[1][1])))
    else:
        print((min((n-1)//2 + 1 - a[0][1] + (n // 2) - b[0][1], (n-1)//2 + 1 - a[0][1] + (n // 2) - b[0][1])))
# Original solution
from collections import defaultdict
ODD = defaultdict(int)
EVEN = defaultdict(int)
ALL = set([])
N = int(eval(input()))

A = list(map(int,input().split()))
for i in range(N):
  ALL.add(A[i])
  if i%2 == 0:
    EVEN[A[i]] += 1
  else:
    ODD[A[i]] += 1
if len(ALL) == 1:
  ans = N//2
  print(ans)
  exit()
modd = max(ODD.values())
meven = max(EVEN.values())
mlodd = [];mleven = []
dicodd = sorted(list(ODD.items()), key=lambda x:x[1], reverse = True)
diceven = sorted(list(EVEN.items()), key=lambda x:x[1], reverse = True)
ans = N
for x, vx in dicodd:
  for y, vy in diceven:
    if x != y:
      temp = N-(vx+vy)
      if ans != temp:
        ans = min(ans,temp)
      else:
        print(ans)
        exit()
print(ans)
exit()
print(ans)


# Optimized solution
from collections import defaultdict
ODD = defaultdict(int)
EVEN = defaultdict(int)
ALL = set([])
N = int(eval(input()))

A = list(map(int,input().split()))
for i in range(N):
  ALL.add(A[i])
  if i%2 == 0:
    EVEN[A[i]] += 1
  else:
    ODD[A[i]] += 1
if len(ALL) == 1:
  ans = N//2
  print(ans)
  exit()
modd = max(ODD.values())
meven = max(EVEN.values())
mlodd = [];mleven = []
dicodd = sorted(list(ODD.items()), key=lambda x:x[1], reverse = True)
diceven = sorted(list(EVEN.items()), key=lambda x:x[1], reverse = True)
ans = N
if len(dicodd) > 1:
  X = [dicodd[0],dicodd[1]]
else:
  X = [dicodd[0]]
if len(diceven) > 1:
  Y = [diceven[0],diceven[1]]
else:
  Y = [diceven[0]]
#print(X)
#print(Y)
for x,v in X:
  for y,w in Y:
    if x == y:
      continue
    temp = N-(v+w)
    ans = min(ans,temp)

print(ans)
# Original solution
from collections import defaultdict
n = int(eval(input()))
v = [int(x) for x in input().split()]

even_ocr = defaultdict(int) # v[0], v[2], ..., で各数が何回現れるか
odd_ocr = defaultdict(int)  # v[1], v[3], ..., で各数が何回現れるか

for i in range(n // 2):
    even_ocr[v[2 * i]] += 1
    odd_ocr[v[2 * i + 1]] += 1

even_max_num = 0;  even_max_ocr = 0;
odd_max_num = 0;  odd_max_ocr = 0;
for (num, ocr) in list(even_ocr.items()):
    if ocr > even_max_ocr:
        even_max_ocr = ocr
        even_max_num = num

for (num, ocr) in list(odd_ocr.items()):
    if ocr > odd_max_ocr:
        odd_max_ocr = ocr
        odd_max_num = num

if even_max_num != odd_max_num:
    ans = n - even_max_ocr - odd_max_ocr
else:
# 偶数番目に一番多く現れる数と奇数番目に一番多く現れる数が同じ
    even_next_num = 0;  even_next_ocr = 0;
    odd_next_num = 0;  odd_next_ocr = 0;
    for (num, ocr) in list(even_ocr.items()):
        if num != even_max_num and ocr > even_next_ocr:
            even_next_ocr = ocr
            even_next_num = num

    for (num, ocr) in list(odd_ocr.items()):
        if num != odd_max_num and ocr > odd_next_ocr:
            odd_next_ocr = ocr
            odd_next_num = num

    if even_next_ocr + odd_max_ocr > even_max_ocr + odd_next_ocr:
        # 偶数番目は二番目に多い数、奇数番目は一番多い数に揃える
        ans = n - even_next_ocr - odd_max_ocr
    else:
        ans = n - even_max_ocr - odd_next_ocr

print(ans)

# Optimized solution
from collections import defaultdict, Counter
n = int(eval(input()))
v = [int(x) for x in input().split()]

cnt_even = Counter(v[0::2])
cnt_odd = Counter(v[1::2])

# [(要素, 出現回数), (要素, 出現回数), ....]
common_even = cnt_even.most_common()
common_odd = cnt_odd.most_common()
if len(common_even) == 1:   # 1種類の数しかない
    common_even.append((0, 0))
if len(common_odd) == 1:
    common_odd.append((0, 0))

# 偶数番目に一番多く現れる数と奇数番目に一番多く現れる数が異なる
if common_even[0][0] != common_odd[0][0]:
    ans = n - common_even[0][1] - common_odd[0][1]
else:
    ans = min(n - common_even[1][1] - common_odd[0][1], \
              n - common_even[0][1] - common_odd[1][1])

print(ans)
# Original solution
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(n: int, v: "List[int]"):
    e = [(len(v[0::2]) - vv, k, 0) for k, vv in list(Counter(v[0::2]).items())]
    o = [(len(v[1::2]) - vv, k, 1) for k, vv in list(Counter(v[1::2]).items())]

    res = [(len(v[0::2]),''), (len(v[1::2]),'')]
    for n, k, t in sorted(e + o):
        if res[t][1] != '':
            continue

        if res[1 - t][1] == k:
            continue

        res[t] = (n, k)
        if res[0][1] != '' and res[1][1] != '':
            break
    return res[0][0] + res[1][0]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    result = solve(n, v)
    print(result)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(n: int, v: "List[int]"):
    e = v[0::2]
    o = v[1::2]

    ec = sorted([(vv, k) for k, vv in list(Counter(e).items())], reverse=True) + [(0, None)]
    oc = sorted([(vv, k) for k, vv in list(Counter(o).items())], reverse=True) + [(0, None)]

    ee1 = ec[0]
    oo1 = oc[1] if oc[0][1] == ee1[1] else oc[0]
    ret1 = len(v) - ee1[0] - oo1[0]

    oo2 = oc[0]
    ee2 = ec[1] if ec[0][1] == oo2[1] else ec[0]
    ret2 = len(v) - ee2[0] - oo2[0]
   
    return min(ret1, ret2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    result = solve(n, v)
    print(result)

if __name__ == '__main__':
    main()
# Original solution
# -*- coding: utf-8 -*-
import collections

def search_b(a_char, a_count, b_most_common, fixed_count):
  thres = fixed_count - a_count
  for (b_char, b_count) in [b for b in b_most_common if b[1] > thres]:
    if a_char != b_char:
      return a_count + b_count
  
  return fixed_count


def search(a_most_common, b_most_common):
  fixed_count = -1
  for (a_char, a_count) in a_most_common:
    fixed_count = search_b(a_char, a_count, b_most_common, fixed_count)
  
  return fixed_count


def main():
  n = int(eval(input()))
  V = list(map(int, input().split()))

  a = V[::2]
  b = V[1::2]
  
  a_counter = collections.Counter(a)
  b_counter = collections.Counter(b)

  a_most_common = a_counter.most_common()
  b_most_common = b_counter.most_common()

  if len(a_most_common) == 1 and len(b_most_common) == 1 and a_most_common[0][0] == b_most_common[0][0]:
    print((n // 2))
    return

  print((n - search(a_most_common, b_most_common)))


if __name__ == '__main__':
  main()


# Optimized solution
# -*- coding: utf-8 -*-
import collections

def search_b(a_char, a_count, b_most_common, fixed_count):
  thres = fixed_count - a_count
  for (b_char, b_count) in [b for b in b_most_common if b[1] > thres]:
    if a_char != b_char:
      return a_count + b_count
  
  return fixed_count


def search(a_most_common, b_most_common):
  fixed_count = -1
  b_max = b_most_common[0][1]

  for (a_char, a_count) in a_most_common:
    if a_count <= fixed_count - b_max:
      break

    fixed_count = search_b(a_char, a_count, b_most_common, fixed_count)
  
  return fixed_count


def main():
  n = int(eval(input()))
  V = list(map(int, input().split()))

  a = V[::2]
  b = V[1::2]
  
  a_counter = collections.Counter(a)
  b_counter = collections.Counter(b)

  a_most_common = a_counter.most_common()
  b_most_common = b_counter.most_common()

  if len(a_most_common) == 1 and len(b_most_common) == 1 and a_most_common[0][0] == b_most_common[0][0]:
    print((n // 2))
    return

  print((n - search(a_most_common, b_most_common)))


if __name__ == '__main__':
  main()
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
b = []
c = []

for i, vv in enumerate(v):
    if i%2 == 0:
        b.append(vv)
    else:
        c.append(vv)

b_set = []
c_set = []

for bb in set(b):
    b_set.append((b.count(bb), bb))
for cc in set(c):
    c_set.append((c.count(cc), cc))

b_set.sort(reverse=True)
b_set.append((0,0))
c_set.sort(reverse=True)
c_set.append((0,0))

if b_set[0][1] != c_set[0][1]:
    ans = n - b_set[0][0] - c_set[0][0]
else:
    try1 = n - b_set[1][0] - c_set[0][0]
    try2 = n - b_set[0][0] - c_set[1][0]
    ans = min(try1,try2)

print(ans)

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
b = []
c = []

for i, vv in enumerate(v):
    if i%2 == 0:
        b.append(vv)
    else:
        c.append(vv)

b_set = {}
c_set = {}

for bb in b:
    if not bb in list(b_set.keys()):
        b_set[bb] = 1
    else:
        b_set[bb] += 1

for cc in c:
    if not cc in list(c_set.keys()):
        c_set[cc] = 1
    else:
        c_set[cc] += 1

b_sorted = []
c_sorted = []

for key, value in list(b_set.items()):
    b_sorted.append([value,key])
for key, value in list(c_set.items()):
    c_sorted.append([value,key])

b_sorted = sorted(b_sorted, reverse=True)
b_sorted += [[0,0]]
c_sorted = sorted(c_sorted, reverse=True)
c_sorted += [[0,0]]


if b_sorted[0][1] != c_sorted[0][1]:
    ans = n - b_sorted[0][0] - c_sorted[0][0]
else:
    try1 = n - b_sorted[1][0] - c_sorted[0][0]
    try2 = n - b_sorted[0][0] - c_sorted[1][0]
    ans = min(try1,try2)

print(ans)
# Original solution
from collections import Counter

n, *v = list(map(int, open(0).read().split()))
vo = Counter(v[::2])
ve = Counter(v[1::2])
vo_mc = vo.most_common()[0]
ve_mc = ve.most_common()[0]
if vo_mc[0] == ve_mc[0]:
    if vo_mc[1] > ve_mc[1]:
        ans = n//2 - vo_mc[1]
        if ve_mc[1] != n//2:
            ans += n//2 - ve.most_common()[1][1]
        else:
            ans += n//2
    elif vo_mc[1] < ve_mc[1]:
        ans =  n//2 - ve_mc[1]
        if vo_mc[1] != n//2:
            ans += n//2 - vo.most_common()[1][1]
        else:
            ans += n//2
    else:
        ans = n
        if ve_mc[1] != n//2:
            ans = min(n//2 - vo_mc[1] + n//2 - ve.most_common()[1][1], ans)
        if vo_mc[1] != n//2:
            ans = min(n//2 - vo.most_common()[1][1] + n//2 - ve_mc[1], ans)
        ans = min(n//2 - vo_mc[1] + n//2, ans)
else:
    ans = n//2 - vo_mc[1] + n//2 - ve_mc[1]
print(ans)

# Optimized solution
from collections import Counter

n, *v = list(map(int, open(0).read().split()))
vo = Counter(v[::2])
ve = Counter(v[1::2])
vo_mc = vo.most_common()[0]
ve_mc = ve.most_common()[0]
if vo_mc[0] == ve_mc[0]:
    ans = n
    if ve_mc[1] != n//2:
        ans = min(n//2 - vo_mc[1] + n//2 - ve.most_common()[1][1], ans)
    if vo_mc[1] != n//2:
        ans = min(n//2 - vo.most_common()[1][1] + n//2 - ve_mc[1], ans)
    ans = min(n//2 - vo_mc[1] + n//2, ans)
else:
    ans = n//2 - vo_mc[1] + n//2 - ve_mc[1]
print(ans)
# Original solution
# 2019-11-10 17:11:42(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
import operator as op
# from scipy.misc import comb # float
# import numpy as np
# import statistics

def main():
    
    n, *v = (int(x) for x in sys.stdin.read().split())

    odds, evens = [], []
    for i in range(n):
        if i % 2 == 0:
            odds.append(v[i])
        else:
            evens.append(v[i])


    o_c = collections.Counter(odds)
    e_c = collections.Counter(evens)
    
    o_c = sorted(list((k, v) for k, v in list(o_c.items())), key=op.itemgetter(1), reverse=True)
    e_c = sorted(list((k, v) for k, v in list(e_c.items())), key=op.itemgetter(1), reverse=True)

    ans = n
    if o_c[0][0] != e_c[0][0]:
        ans = n - o_c[0][1] - e_c[0][1]
    else:
        if len(o_c) == 1 and len(e_c) == 1:
            ans = n - n // 2
        elif len(o_c) == 1 and len(e_c) >= 2:
            ans = n - e_c[1][1]
        elif len(o_c) >= 2 and len(e_c) == 1:
            ans = n - o_c[1][1]
        else:
            ans = n - max(o_c[0][1] + e_c[1][1], o_c[1][1] + e_c[0][1])
    
    print(ans)

if __name__ == "__main__":
    main()


# Optimized solution
import sys
from collections import Counter

n, *v = list(map(int, sys.stdin.read().split()))

def main():
    c1 = sorted(list(Counter(v[::2]).items()), reverse=True, key=lambda x: x[1])
    c2 = sorted(list(Counter(v[1::2]).items()), reverse=True, key=lambda x: x[1])
    
    if c1[0][0] != c2[0][0]:
        return n // 2 - c1[0][1] + n // 2 - c2[0][1]
    else:
        if len(c1) == len(c2) == 1:
            return n // 2
        elif len(c1) == 1:
            return n // 2 - c2[1][1]
        elif len(c2) == 1:
            return n // 2 - c1[1][1]
        else:
            return n - max(c1[0][1] + c2[1][1], c1[1][1] + c2[0][1])

if __name__ == '__main__':
    ans = main()
    print(ans)