CodeEff/ECCO huggingface dataset:
# Original solution
N=int(eval(input()))
lv=list(map(int,input().split()))
dev={}
dod={}
#cev=0#devの種類数
#cod=0#dodの種類数
max1_ev=[0,0]#数字,個数
max2_ev=[0,0]
max1_od=[0,0]#数字,個数
max2_od=[0,0]

for i in range(N):
    if i%2==0:#even
        #max1_ev=[0,0]#数字,個数
        #max2_ev=[0,0]
        #毎回初期化していた！！

        if lv[i] in dev:#辞書の更新
            dev[lv[i]]+=1
        else:
            dev[lv[i]]=1
            #maxの更新
            #cev+=1
            #if cev==1:
            #    max1_ev=[i,lv[i]]
            #elif cev==2:
            #    max2_ev=[i,lv[i]]
        ##3種目以降
        #最大個数の更新
        if dev[lv[i]]>max1_ev[1]:
            max1_ev=[lv[i],dev[lv[i]]]
        #elif dev[lv[i]]>max2_ev[1]:
        elif dev[lv[i]]>=max2_ev[1]:
            max2_ev=[lv[i],dev[lv[i]]]
        #print("dev[lv[i]]",dev[lv[i]])
        #print("max1__ev[1]",max1_ev[1])
        #print("max1_ev",max1_ev)
        #print("max2_ev",max2_ev)
        #if i==0:
        #    max1=[0,1]
        #elif i==1:
        #    max2
    else:#odd
        #max1_od=[0,0]
        #max2_od=[0,0]
        if lv[i] in dod:
            dod[lv[i]]+=1
        else:
            dod[lv[i]]=1
        if dod[lv[i]]>max1_od[1]:
            max1_od=[lv[i],dod[lv[i]]]
        #elif dod[lv[i]]>max2_od[1]:
        elif dod[lv[i]]>=max2_od[1]:
            max2_od=[lv[i],dod[lv[i]]]
#print("dev",dev)#ok
#print("dod",dod)#ok
#print("max1_ev",max1_ev)
#print("max2_ev",max2_ev)


#if len(dev)==1 and len(dod)==1:
#    print(int(N/2))
#elif len(dev)==1:
    #for i in range(len(dod)):
    #    if i==0:
    #        max1_od=
#    if max1_ev[0]!=max1_od[0]:
#        print(N-max1_ev[1]-max1_od[1])
##        print(max)
if max1_ev[0]!=max1_od[0]:
    print((N-max1_ev[1]-max1_od[1]))
elif len(dev)==1 and len(dod)==1:
    print((int(N/2)))
elif len(dev)==1:
    print((int(N/2)-max2_od[1]))
elif len(dod)==1:
    print((int(N/2)-max2_ev[1]))
else:
    #print(max(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1]))#minをmaxとしていた
    print((min(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1])))


# Optimized solution
N=int(eval(input()))
lv=list(map(int,input().split()))
dev={}
dod={}
for i in range(N):
    if i%2==0:#even
        if lv[i] in dev:
            dev[lv[i]]+=1
        else:
            dev[lv[i]]=1
    else:#odd
        if lv[i] in dod:
            dod[lv[i]]+=1
        else:
            dod[lv[i]]=1

max1_ev=[0,0]
max2_ev=[0,0]
max1_od=[0,0]
max2_od=[0,0]
#for i in range(len(dev)):
for v in dev:#max even
    if dev[v]>max1_ev[1]:
        a=max1_ev
        max1_ev=[v,dev[v]]
        max2_ev=a
    elif dev[v]>max2_ev[1]:
        max2_ev=[v,dev[v]]
for v in dod:#max odd
    if dod[v]>max1_od[1]:
        a=max1_od
        max1_od=[v,dod[v]]
        max2_od=a
    elif dod[v]>max2_od[1]:
        max2_od=[v,dod[v]]
if max1_ev[0]!=max1_od[0]:
    print((N-max1_ev[1]-max1_od[1]))
else:
    print((min(N-max1_ev[1]-max2_od[1],N-max2_ev[1]-max1_od[1])))
# Original solution
import collections

N = int(eval(input()))
V = [int(x) for x in input().split()]

Va, Vb = [], []
for i in range(N):
    if i % 2 == 0:
        Va.append(V[i])
    else:
        Vb.append(V[i])

Va_most = collections.Counter(Va).most_common()
Vb_most = collections.Counter(Vb).most_common()

if N == collections.Counter(V).most_common()[0][1]:
    print((N//2))
    exit()

if Va_most[0][0] == Vb_most[0][0]:
    typea = 10 ** 10
    if len(Vb_most) >= 2:
        typea = (len(Va) - Va_most[0][1]) + (len(Vb) - Vb_most[1][1])
    typeb = 10 ** 10
    if len(Va_most) >= 2:
        typeb = (len(Va) - Va_most[1][1]) + (len(Vb) - Vb_most[0][1])
    print((min(typea, typeb)))
    exit()

print(((len(Va) - Va_most[0][1]) + (len(Vb) - Vb_most[0][1])))

# Optimized solution
import itertools
from collections import Counter

N = int(eval(input()))
V = [int(x) for x in input().split()]
EV_cnt = Counter(V[::2])
OD_cnt = Counter(V[1::2])

EV_cnt[-1] = 0
OD_cnt[-2] = 0

EV = EV_cnt.most_common(2)
OD = OD_cnt.most_common(2)

ans = N
for (k1,v1), (k2,v2) in itertools.product(EV,OD):
    if k1 == k2:
        continue
    x = (N - v1 - v2)
    if ans > x:
        ans = x

print(ans)
# Original solution
import collections
n = int(eval(input()))
V = [int(i) for i in input().split()]
E,O = [],[]
E_cnt2,O_cnt2 = 0,0
for i in range(n):
    if i%2:
        E.append(V[i])
    else:
        O.append(V[i])
e = collections.Counter(E)
tmp = e.most_common()
E_mode,E_cnt = tmp[0][0],tmp[0][1]
if len(tmp)>=2:
    E_cnt2 = tmp[1][1]

o = collections.Counter(O)
tmp = o.most_common()
O_mode,O_cnt = tmp[0][0],tmp[0][1]
if len(tmp)>=2:
    O_cnt2 = tmp[1][1]
if E_mode!=O_mode:
    print((len(E)-E_cnt+len(O)-O_cnt))
else:
    print((min((len(E)-E_cnt+len(O)-O_cnt2),len(E)-E_cnt2+len(O)-O_cnt)))




# Optimized solution
import collections
n = int(eval(input()))
v = [int(i) for i in input().split()]
kisu = []
gusu = []

kisu = v[::2]
gusu = v[1::2]

kisu_cnt = collections.Counter(kisu)
gusu_cnt = collections.Counter(gusu)

kisu_cnt = kisu_cnt.most_common(2)#引数にnを用意すると，出現回数の多い順にn子だけ呼び出せる
gusu_cnt = gusu_cnt.most_common(2)
kisu_most  = 0
gusu_most = 0
if kisu_cnt[0][0]!=gusu_cnt[0][0]:
    print((n-kisu_cnt[0][1]-gusu_cnt[0][1]))
    exit()
else:
    if len(kisu_cnt)==1 or len(gusu_cnt)==1:
        print((n//2))
        exit()
    else:
        print((n-max(kisu_cnt[0][1]+gusu_cnt[1][1],kisu_cnt[1][1]+gusu_cnt[0][1])))
# Original solution
# coding: utf-8
# Your code here!
n=int(eval(input()))
v=[int(x) for x in input().split()]
if len(set(v))==1:
    print((n//2))
    import sys
    sys.exit()
from collections import Counter
v1=[]
v2=[]
for i in range(n):
    if i%2==0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v1=Counter(v1)
v2=Counter(v2)
ans=10**10
# print(v1,v2)
for i1 in v1.most_common():
    for i2 in v2.most_common():
        # print(n-i1[1]-i2[1],i1,i2)
        ans=min(n-i1[1]-i2[1],ans)
print(ans)

# Optimized solution
# coding: utf-8
# Your code here!
n=int(eval(input()))
v=[int(x) for x in input().split()]
if len(set(v))==1:
    print((n//2))
    import sys
    sys.exit()
from collections import Counter
v1=[]
v2=[]
for i in range(n):
    if i%2==0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v1=Counter(v1)
v2=Counter(v2)
ans=10**10
# print(v1,v2)
for i1 in v1.most_common(min(len(v1),10)):
    for i2 in v2.most_common(min(len(v1),10)):
        # print(n-i1[1]-i2[1],i1,i2)
        if i1==i2:
            continue
        ans=min(n-i1[1]-i2[1],ans)
print(ans)
# Original solution
from collections import Counter
n = int(input())
V = list(map(int, input().split()))

Odd, Evn = [], []
for i in range(n):
    Evn.append(V[i]) if i%2 == 0 else Odd.append(V[i])
Evn = sorted( dict(Counter(Evn)).items(), key = lambda x:x[1])
Odd = sorted( dict(Counter(Odd)).items(), key = lambda x:x[1])

cnt = -1
for evn in Evn:
    for odd in Odd:
        if evn[0] != odd[0]:
            cnt = max(cnt, evn[1]+odd[1])
print(n-cnt) if cnt > 0 else print(n//2)


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

Odd, Evn = [], []
for i in range(n):
    Evn.append(V[i]) if i%2 == 0 else Odd.append(V[i])
Evn = sorted( dict(Counter(Evn)).items(), key = lambda x:x[1], reverse=True)
Odd = sorted( dict(Counter(Odd)).items(), key = lambda x:x[1], reverse=True)

cnt = -1
for evn in Evn[0:2]:
    for odd in Odd[0:2]:
        if evn[0] != odd[0]:
            cnt = max(cnt, evn[1]+odd[1])
print(n-cnt) if cnt > 0 else print(n//2)
# Original solution
n = int(eval(input()))
v = list(map(int,input().split()))
v_odd = []
v_even = []
for i in range(n//2):
    v_odd.append(v[2*i])
    v_even.append(v[2*i+1])
p1 = 0
p2 = 0
q1 = 0
q2 = 0
o_max = -1
e_max = -1
for i in range(n//2):
    a = v_odd[i]
    b = v_even[i]
    x = v_odd.count(a)
    y = v_even.count(b)
    if p1 <= x:
        if o_max != a:
            o_max = a
            p2 = p1
            p1 = x
    else:
        if x > p2:
            p2 = x
    if q1 <= y:
        if e_max != b:
            e_max = b
            q2 = q1
            q1 = y
    else:
        if y > q2:
            q2 = y
s = p1 + q1
if o_max == e_max:
    s = max(p1+q2,q1+p2)
ans = n-s
print(ans)

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
v_odd = []
v_even = []
d_odd = {}
d_even = {}
o = []
e = []
for i in range(n//2):
    a = v[2*i]
    b = v[2*i+1]
    if a in d_odd:
        d_odd[a] += 1
    else:
        d_odd[a] = 1
        o.append(a)
    if b in d_even:
        d_even[b] += 1
    else:
        d_even[b] = 1
        e.append(b)
O = 0
E = 0
o_max = 0
o_second = 0
e_max = 0
e_second = 0
for i in o:
    x = d_odd[i]
    if x >= o_max:
        O = i
        o_max = x
d_odd.pop(O)
o.remove(O)
for i in o:
    x = d_odd[i]
    if x >= o_second:
        o_second = x
for i in e:
    y = d_even[i]
    if y >= e_max:
        E = i
        e_max = y
d_even.pop(E)
e.remove(E)
for i in e:
    y = d_even[i]
    if y >= e_second:
        e_second = y
if O == E:
    m = max(o_max+e_second,e_max+o_second)
else:
    m = o_max + e_max
print((n-m))
# Original solution
from collections import Counter
from operator import itemgetter

n = int(eval(input()))
v = tuple(map(int, input().split()))

evens = Counter(v[::2])
odds = Counter(v[1::2])

evens = list(sorted(list(evens.items()), key=itemgetter(1), reverse=True))
odds = list(sorted(list(odds.items()), key=itemgetter(1), reverse=True))
# 出現数降順ソート

ans = n
for even_num, even_cnt in evens[:2] + [(-1, 0)]:
    for odd_num, odd_cnt in odds[:2] + [(-1, 0)]:
        if even_num == odd_num: continue
        ans = min(ans, n - even_cnt - odd_cnt)
# evensとoddsの書き換え先候補として、出現率上位2数を調べる
# 同じ数は使用できない
# 1111のようにevensとoddsがともに同じ数字しかない場合に備え、
# vの要素に含まれない値-1が0個あると考える(片方の-1をすべて書き換えると考える）

print(ans)


# Optimized solution
from collections import Counter
from itertools import product

NUM = 0
CNT = 1

n = int(eval(input()))
v = tuple(map(int, input().split()))

c_odd = Counter(v[1::2])
c_even = Counter(v[0::2])

odd_12 = c_odd.most_common()[:2]
even_12 = c_even.most_common()[:2]
# [(num, cnt),(num, cnt)]

ans = n
for o, e in product(odd_12 + [(-1, 0)], even_12 + [(-1, 0)]):
    # print(o, e)
    if o[NUM] == e[NUM]:
        continue
    ans = min(ans, n - (o[CNT] + e[CNT]))
print(ans)
# Original solution
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from collections import Counter

def solve():
    n = II()
    V = LI()
    
    even = V[::2]
    odd = V[1::2]
    harf = n // 2
    
    ec = Counter(even).most_common()
    oc = Counter(odd).most_common()
    #print(n)
    #print(ec[:3])
    #print(oc[:3])

    
    if ec[0][0] == oc[0][0]:
      # 小さい方を変える
      if ec[0][1] < oc[0][1]:
        ans = n - oc[0][1] - (ec[1][1] if len(ec) > 1 else 0)
      elif ec[0][1] == oc[0][1]:
        ans = n - ec[0][1] - max((ec[1][1] if len(ec) > 1 else 0), (oc[1][1] if len(oc) > 1 else 0))
      else:
        ans = n - ec[0][1] - (oc[1][1] if len(oc) > 1 else 0)
    else:
      ans = n - ec[0][1] - oc[0][1]
    
    print(ans)


if __name__ == '__main__':
    solve()


# Optimized solution
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(eval(input()))

def MI(): return list(map(int, input().split()))
def MI1(): return list(map(int1, input().split()))

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from collections import Counter

def solve():
    n = II()
    V = LI()
    
    even = V[::2]
    odd = V[1::2]
    harf = n // 2
    
    ec = Counter(even).most_common()
    oc = Counter(odd).most_common()
    #print(n)
    #print(ec[:3])
    #print(oc[:3])
    e1 = ec[0][1]
    o1 = oc[0][1]
    
    if ec[0][0] == oc[0][0]:
      # 小さい方を変える
      e2 = ec[1][1] if len(ec) > 1 else 0
      o2 = oc[1][1] if len(oc) > 1 else 0
      
      ans = min(n - e1 - o2, n - o1 - e2)
    else:
      ans = n - e1 - o1
    
    print(ans)


if __name__ == '__main__':
    solve()
# Original solution
from collections import Counter
from itertools import product

N=int(eval(input()))
V=list(map(int,input().split()))

# 出現回数
O_cnt,E_cnt=Counter(V[::2]),Counter(V[1::2])
O_cnt[-1]=0
E_cnt[-2]=0

# 出現回数順
O_key,E_key=O_cnt.most_common(2),E_cnt.most_common(2)

ans=float('inf')

for O_k,E_k in product(O_key,E_key):
    if O_k[0]!=E_k[0]:
	    ans=min(ans,N-O_k[1]-E_k[1])
print(ans)


# Optimized solution
from collections import Counter

N=int(eval(input()))
V=list(map(int,input().split()))

v1=V[::2]
v2=V[1::2]

cntV1,cntV2=Counter(v1),Counter(v2)
cntV1,cntV2=cntV1.most_common(2),cntV2.most_common(2)
cntV1.append((0,0))
cntV2.append((0,0))

if cntV1[0][0]!=cntV2[0][0]:
    ans=N-(cntV1[0][1]+cntV2[0][1])
else:
    ans=max(cntV1[0][1]+cntV2[1][1],cntV1[1][1]+cntV2[0][1])
    ans=N-ans

print(ans)
# Original solution
from collections import Counter

n = int(eval(input()))
v=list(map(int,input().split()))
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print((n-(a[0][1]+b[0][1])))
else:
    print((min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))))

# Optimized solution

from collections import Counter


def resolve():
    N = int(eval(input()))
    A = list(map(int, input().split()))

    O = Counter(A[::2])
    E = Counter(A[1::2])

    most_O = O.most_common(2)
    most_E = E.most_common(2)
    # 番兵
    most_O.append((0, 0))
    most_E.append((0, 0))

    cnt = 0
    # key comp
    if most_O[0][0] == most_E[0][0]:
        # value
        res1 = most_O[0][1] + most_E[1][1]
        res2 = most_O[1][1] + most_E[0][1]
        cnt = max(res1, res2)
    else:
        cnt = most_O[0][1] + most_E[0][1]

    # 数字が少ないものを書き換える為、Nで引く
    print((N - cnt))


if __name__ == "__main__":
    resolve()
# Original solution
# -*- coding: utf-8 -*-

N = int(eval(input()))
vN = list(map(int, input().split()))

even = {}
odd = {}
# 奇数番目と偶数番目に分けて集計
for i in range(N):
    if i % 2 == 0:
        even[vN[i]] = even.get(vN[i], 0) + 1
    else:
        odd[vN[i]] = odd.get(vN[i], 0) + 1

# 集計数の多い順ソート
even_sorted = sorted(list(even.items()), key=lambda x: x[1], reverse=True)
odd_sorted = sorted(list(odd.items()), key=lambda x: x[1], reverse=True)

# 1番多い数字が同じだった場合の別処理
if even_sorted[0][0] == odd_sorted[0][0]:
    # 偶奇それぞれ数字が1種類しかない場合の別処理
    if len(even_sorted) == 1 and len(odd_sorted) > 1:
        print((N - even_sorted[0][1] - odd_sorted[1][1]))
    elif len(even_sorted) > 1 and len(odd_sorted) == 1:
        print((N - even_sorted[1][1] - odd_sorted[0][1]))  
    elif len(even_sorted) == 1 and len(odd_sorted) == 1:
        print((N // 2))
    else:
        # 偶奇それぞれを2番目にしてみて、数の大きい方
        print((N - max(even_sorted[1][1] + odd_sorted[0][1], even_sorted[0][1] + odd_sorted[1][1])))
else:
    print((N - even_sorted[0][1] - odd_sorted[0][1]))

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

N = int(eval(input()))
vN = list(map(int, input().split()))

even = {}
odd = {}
# 奇数番目と偶数番目に分けて集計
for i in range(N):
    if i % 2 == 0:
        even[vN[i]] = even.get(vN[i], 0) + 1
    else:
        odd[vN[i]] = odd.get(vN[i], 0) + 1

# 集計数の多い順ソート
even_sorted = sorted(list(even.items()), key=lambda x: x[1], reverse=True)
odd_sorted = sorted(list(odd.items()), key=lambda x: x[1], reverse=True)

# 1番多い数字が同じだった場合の別処理
if even_sorted[0][0] == odd_sorted[0][0]:
    # 偶奇それぞれ数字が1種類しかない場合は、この後の比較処理のためにダミーの0を入れておく
    if len(even_sorted) == 1:
        even_sorted.append((0, 0))
    if len(odd_sorted) == 1:
        odd_sorted.append((0, 0))
    # 偶奇それぞれを2番目にしてみて、数の大きい方
    print((N - max(even_sorted[1][1] + odd_sorted[0][1], even_sorted[0][1] + odd_sorted[1][1])))
else:
    print((N - even_sorted[0][1] - odd_sorted[0][1]))
# Original solution
from collections import Counter
n = int(eval(input()))
v = list(map(int, input().split()))
v1, v2 = [], []
for i in range(n):
    if i%2:
        v1.append(v[i])
    else:
        v2.append(v[i])
vv1 = Counter(v1).most_common()
vv2 = Counter(v2).most_common()
if vv1[0] != vv2[0]:
    print((n - vv1[0][1] - vv2[0][1]))
else:
    if len(vv1) == len(vv2) == 1:
        print((n - max(vv1[0][1], vv2[0][1])))
    elif len(vv1) == 1 and len(vv2) == 2:
        print((n - vv1[0][1] - vv2[1][1]))
    elif len(vv1) == 2 and len(vv2) == 1:
        print((n - vv1[1][1] - vv2[0][1]))
    else:
        print((n - max(vv1[1][1] + vv2[0][1], vv1[0][1] + vv2[1][1])))

# Optimized solution
from collections import Counter
n = int(eval(input()))
v = list(map(int, input().split()))
v1, v2 = v[::2], v[1::2]
vv1 = Counter(v1).most_common()
vv2 = Counter(v2).most_common()

if len(set(v)) == 1:
    print((n//2))
elif vv1[0] != vv2[0]:
    print((n - vv1[0][1] - vv2[0][1]))
else:
    print((n - max(vv1[1][1] + vv2[0][1], vv1[0][1] + vv2[1][1])))
# Original solution
from collections import Counter

N = int(eval(input()))
V = list(map(int, input().split()))

if len(set(V)) == 1:
    print((len(V)//2))
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)

vodd = V_odd_counter.most_common()
veven = V_even_counter.most_common()
vlen = len(V)
while True:
    if vodd[0][0] != veven[0][0]:
        print((vlen - vodd[0][1] - veven[0][1]))
        exit()
    else:
        print((min(vlen - vodd[1][1] - veven[0][1],
                    vlen - vodd[0][1] - veven[1][1])))

# Optimized solution
from collections import Counter

N = int(eval(input()))
V = list(map(int, input().split()))

if len(set(V)) == 1:
    print((len(V)//2))
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)

vodd = V_odd_counter.most_common()
veven = V_even_counter.most_common()
vlen = len(V)
while True:
    if vodd[0][0] != veven[0][0]:
        print((vlen - vodd[0][1] - veven[0][1]))
        exit()
    else:
        print((min(vlen - vodd[1][1] - veven[0][1],
                    vlen - vodd[0][1] - veven[1][1])))
        exit()
# Original solution
from collections import Counter

N = int(eval(input()))
V = list(map(int, input().split()))

s1 = Counter(V).most_common(2)[0]
s2 = Counter(V).most_common(2)[0]
V1 = V[0::2]
V2 = V[1::2]
c1 = c2 = c3 = c4 = 0
Z1 = Counter(V1)
Z2 = Counter(V2)
x1, c1 = Z1.most_common(1)[0]
x2, c2 = Z2.most_common(1)[0]
if len(Z1) > 1:
    x3, c3 = Counter(V1).most_common(2)[1]
if len(Z2) > 1:
    x4, c4 = Counter(V2).most_common(2)[1]
if x1 == x2:
    a = max(c1+c4, c2+c3)
    print((N-a))
else:
    print((N - c1 - c2))

# Optimized solution
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 奇数番目の最頻値と偶数番目の最頻値が同じ時に注意
N = ir()
V = lr()
odd = V[::2]
even = V[1::2]
cnt_odd = Counter(odd)
cnt_even = Counter(even)
cnt_odd_most = cnt_odd.most_common()
cnt_even_most = cnt_even.most_common()
if cnt_odd_most[0][0] == cnt_even_most[0][0]:
    answer = N
    if len(cnt_odd_most) > 1:
        temp = N - cnt_odd_most[1][1] - cnt_even_most[0][1]
        answer = min(answer, temp)
    if len(cnt_even_most) > 1:
        temp = N - cnt_odd_most[0][1] - cnt_even_most[1][1]
        answer = min(answer, temp)
    if answer == N:
        answer = N // 2
else:
    answer = N - cnt_odd_most[0][1] - cnt_even_most[0][1]

print(answer)
# Original solution
from bisect import bisect_left as bl
from bisect import bisect_right as br
n = int(eval(input()))
v = list(map(int, input().split()))
ev = []
od = []
for i in range(n):
    if i % 2 == 0:
        ev.append(v[i])
    else:
        od.append(v[i])
ev.sort()
od.sort()
m = 0
oo = [[0, 0]]
ii = [[0, 0]]
while True:
    oo.append([ev[m], br(ev, ev[m], 0, n//2)-bl(ev, ev[m], 0, n//2)])
    m += ev.count(ev[m])
    if m >= n//2:
        break
m = 0
while True:
    ii.append([od[m], br(od, od[m], 0, n//2)-bl(od, od[m], 0, n//2)])
    m += od.count(od[m])
    if m >= n//2:
        break
ii.sort(key=lambda x: x[1], reverse=True)
oo.sort(key=lambda x: x[1], reverse=True)
if ii[0][0] != oo[0][0]:
    print((n - oo[0][1] - ii[0][1]))
else:
    print((min(n - oo[1][1] - ii[0][1], n - oo[0][1] - ii[1][1])))

# Optimized solution
n = int(eval(input()))
v = list(map(int, input().split()))
ev = [0]*(max(v)+1)
od = [0]*(max(v)+1)
for i in range(n):
    if i % 2 == 0:
        ev[v[i]-1] += 1
    else:
        od[v[i] - 1] += 1
e = sorted(ev)
o = sorted(od)
if ev.index(e[-1]) == od.index(o[-1]) and e[-2] != e[-1] and o[-2] != o[-1]:
    print((n-max(e[-1]+o[-2], e[-2]+o[-1])))
else:
    print((n-e[-1]-o[-1]))
# Original solution
from collections import Counter
N = int(eval(input()))
a = list(map(int,input().split()))
E = []
O = []
for k in range(N):
    if k%2 == 0:
        E.append(a[k])
    else:
        O.append(a[k])
e = Counter(E).most_common()
o = Counter(O).most_common()

if e[0][0] != o[0][0]:
    print((N-e[0][1]-o[0][1]))
else:
    if len(e) >= 2 and len(o) >= 2:
        print((N-e[0][1]-max(e[1][1],o[1][1])))
    elif len(e) >= 2 and len(o) == 1:
        print((N//2-e[1][1]))
    elif len(e) == 1 and len(o) >= 2:
        print((N//2-o[1][1]))
    else:
        print((N//2))


# Optimized solution
from collections import Counter
n = int(eval(input()))
a = list(map(int,input().split()))
e = [a[k] for k in range(0,n,2)]
o = [a[k] for k in range(1,n,2)]
C = Counter(e).most_common()
D = Counter(o).most_common()
if C[0][0] != D[0][0]:
    print((n-C[0][1]-D[0][1]))
else:
    if len(C) == len(D) == 1:
        print((n//2))
    elif len(C) == 1 and len(D) > 1:
        print((n-C[0][1]-D[1][1]))
    elif len(D) == 1 and len(C) > 1:
        print((n-D[0][1]-C[1][1]))
    else:
        print((n-max(D[0][1]+C[1][1],C[0][1]+D[1][1])))
# Original solution
n = int(eval(input()))
li = list(map(int,input().split()))

li2 = li[::2]
li3 = li[1::2]
max2,max22,max3,max33 = [0,0,0,0]

for i in li2:
    a = li2.count(i)
    if a > max2:
        max22 = max2
        max2 = a
        b = i
    elif a > max22 and i != b:
        max22 = a

for i in li3:
    a = li3.count(i)
    if a > max3:
        max33 = max3
        max3 = a
        c = i
    elif a > max33 and i != c:
        max33 = a

if b == c:
    print((max(n-max22-max3,n-max2-max33)))
else:
    print((n-max2-max3))


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

cnt1 = {}
cnt2 = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] in cnt1:
            cnt1[v[i]] += 1
        else:
            cnt1[v[i]] = 1
    else:
        if v[i] in cnt2:
            cnt2[v[i]] += 1
        else:
            cnt2[v[i]] = 1

sorted_cnt1 = sorted(list(cnt1.items()), key = lambda x: x[1], reverse = True)
sorted_cnt2 = sorted(list(cnt2.items()), key = lambda x: x[1], reverse = True)

sorted_cnt1.append((-1,0))
sorted_cnt2.append((-1,0))

if sorted_cnt1[0][0] != sorted_cnt2[0][0]:
    print((n - sorted_cnt1[0][1] - sorted_cnt2[0][1]))
else:
    print((n - max(sorted_cnt1[0][1] + sorted_cnt2[1][1], sorted_cnt1[1][1]+sorted_cnt2[0][1])))