A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:
 - For each i = 1,2,..., n-2, a_i = a_{i+2}.
 - Exactly two different numbers appear in the sequence.
You are given a sequence v_1,v_2,...,v_n whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

-----Constraints-----
 - 2 \leq n \leq 10^5
 - n is even.
 - 1 \leq v_i \leq 10^5
 - v_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
n
v_1 v_2 ... v_n

-----Output-----
Print the minimum number of elements that needs to be replaced.

-----Sample Input-----
4
3 1 3 2

-----Sample Output-----
1

The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.

Difficulty: introductory

Starter code:

Solutions:
n = int(input())
v = list(map(int, input().split()))
odd = [0] * (10 ** 5 + 5)
even = [0] * (10 ** 5 + 5)
for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1
sum_odd = sum(odd)
sum_even = sum(even)
ans = sum_odd + sum_even
max_odd = max(odd)
max_even = max(even)
if odd.index(max_odd) != even.index(max_even):
    print(sum_odd + sum_even - max_even - max_odd)
else:
    odd.sort()
    even.sort()
    if odd[-1] - odd[-2] > even[-1] - even[-2]:
        ans -= odd[-1] + even[-2]
    else:
        ans -= odd[-2] + even[-1]
    print(ans)

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
import collections


# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, Vi):
    V1 = Vi[::2]
    V2 = Vi[1::2]
    c_V1 = dict(collections.Counter(V1))
    c_V2 = dict(collections.Counter(V2))
    c_V1 = sorted(list(c_V1.items()), key=lambda x: x[1], reverse=True)
    c_V2 = sorted(list(c_V2.items()), key=lambda x: x[1], reverse=True)
    c_V1.append((-1, 0))
    c_V2.append((-1, 0))
    ans = 0
    if c_V1[0][0] == c_V2[0][0]:
        ans = min(len(V1) - c_V1[0][1] + len(V2) - c_V2[1][1],
                  len(V1) - c_V1[1][1] + len(V2) - c_V2[0][1])
    else:
        ans = len(V1) - c_V1[0][1] + len(V2) - c_V2[0][1]
    print(ans)


def __starting_point():
    N = int(input())
    Vi = [int(i) for i in input().split()]
    solve(N, Vi)

    # # test
    # from random import randint
    # from func import random_str


__starting_point()

import collections
N = int(input())
v = list(map(int,input().split()))
v1,v2 = v[::2],v[1::2]
A1 = collections.Counter(v1)
A2 = collections.Counter(v2)
B = list(A1.values())
C = list(A2.values())
B.sort(reverse=True)
C.sort(reverse=True)

if A1.most_common()[0][0] == A2.most_common()[0][0]:
    if len(A1) == 1:
        ans = N//2
    else:
        if B[1] > C[1]: ans = N//2 - B[0] + N//2 - B[1]
        else: ans = N//2 - B[0] + N//2 - C[1]

else:
    ans = N//2 - B[0] + N//2 - C[0]
print(ans)

import collections

n = int(input())
n_half = n//2
v = list(map(int, input().split()))
v_gusu = v[0::2]
v_odd = v[1::2]
ans = 0
c1 = collections.Counter(v)
c2 = collections.Counter(v_gusu)
c3 = collections.Counter(v_odd)

if c1.most_common()[0][1] == n:
    print(n_half)
    return

if c2.most_common()[0][0] == c3.most_common()[0][0]:
    print(min((n_half - c2.most_common()[1][1]) + (n_half - c3.most_common()[0][1]),(n_half - c2.most_common()[0][1]) + (n_half - c3.most_common()[1][1])))
    return
else:
    print((n_half - c2.most_common()[0][1]) + (n_half - c3.most_common()[0][1]))
    return

from collections import Counter
n = int(input())
a = list(map(int,input().split()))

e = Counter(a[0::2]).most_common()
o = Counter(a[1::2]).most_common()
e.append((0, 0))
o.append((0, 0))

if e[0][0] != o[0][0]:
  print(n - o[0][1] - e[0][1])
else:
  print(min(n-o[0][1] -e[1][1],n-o[1][1] -e[0][1]))

import collections
import math

n=int(input())
a=list(map(int,input().split()))
ev=[a[2*i] for i in range(n//2)]
od=[a[2*i+1] for i in range(n//2)]

ccev=collections.Counter(ev)
ccod=collections.Counter(od)

mcev=ccev.most_common()
mcod=ccod.most_common()

if mcev[0][0]!=mcod[0][0]:
    print((n-mcev[0][1]-mcod[0][1]))
    return
elif len(mcev)==1 and len(mcod)==1:
    print((n-mcev[0][1]))
    return
elif len(mcev)==1:
    print((n-mcod[1][1]))
    return
elif len(mcod)==1:
    print((n-mcev[1][1]))
    return
else:
    tt=max(mcev[1][1],mcod[1][1])
    print((n-mcev[0][1]-tt))
    return


n = int(input())
v = list(map(int,input().split()))
v0 = v[0:n-1:2]
v1 = v[1:n:2]
from collections import Counter
V0 = Counter(v0)
V1 = Counter(v1)
if V0.most_common()[0][0] != V1.most_common()[0][0]:
    a = V0.most_common()[0][1]
    b = V1.most_common()[0][1]
else:
    if V0.most_common()[0][1] > V1.most_common()[0][1]:
        if len(V1) > 1:
            a = V0.most_common()[0][1]
            b = V1.most_common()[1][1]
        else:
            a = V0.most_common()[0][1]
            b = 0
    elif V0.most_common()[0][1] < V1.most_common()[0][1]:
        if len(V0) > 1:
            a = V1.most_common()[0][1]
            b = V0.most_common()[1][1]
        else:
            a = 0
            b = V1.most_common()[0][1]
    else:
        if len(V0) == 1 and len(V1) == 1:
            a = 0
            b = V0.most_common()[0][1]
        elif len(V0) == 1:
            a = V0.most_common()[0][1]
            b = V1.most_common()[1][1]
        elif len(V1) == 1:
            a = V0.most_common()[1][1]
            b = V1.most_common()[0][1]
        else:
            a = V0.most_common()[0][1]
            b = max(V0.most_common()[1][1],V1.most_common()[1][1])
print((n-a-b))


import collections
n = int(input())
lsp = list(map(int,input().split()))
lse = []
lso = []
for i in range(n):
    if i%2 == 0:
        lse.append(lsp[i])
    else:
        lso.append(lsp[i])

countere = collections.Counter(lse)
countero = collections.Counter(lso)

valuee = sorted(list(countere.values()),reverse=True)+[0]
valueo = sorted(list(countero.values()),reverse=True)+[0]

keyse = []
for i in countere.keys():
    if countere[i] == valuee[0]:
        keyse.append(i)
keyso = []
for i in countero.keys():
    if countero[i] == valueo[0]:
        keyso.append(i)
factor = 0
if len(keyse) == 1 and len(keyso) == 1 and keyso == keyse:
    factor = min(valuee[0]-valuee[1],valueo[0]-valueo[1])

print(n-valuee[0]-valueo[0]+factor)

N = int(input())
V = list(map(int,input().split()))
O = []
E = []
nums_O = []
nums_E = []

for i in range(0,N,2):
  O.append(V[i])
  E.append(V[i+1])

for j in range(100000):
  nums_O.append([0,j])
  nums_E.append([0,j])

for k in range(N//2):
  nums_O[O[k]-1][0] += 1
  nums_E[E[k]-1][0] += 1
  
nums_O.sort()
nums_E.sort()
##print(O,E,nums_O[-1],nums_E[-1])
if nums_O[-1][1] != nums_E[-1][1]:
  print(N-(nums_O[-1][0] + nums_E[-1][0]))
else:
  print(N-max(nums_E[-2][0]+nums_O[-1][0],nums_O[-2][0]+nums_E[-1][0]))

N=int(input())
Z=list(map(int,input().split()))
from collections import Counter
c=Counter(Z[::2]).most_common(2)+[(0,0)]
c2=Counter(Z[1::2]).most_common(2)+[(0,0)]
if c[0][0]!=c2[0][0]:
    print(N-c[0][1]-c2[0][1])
else:
    print(min(N-c[1][1]-c2[0][1],N-c[0][1]-c2[1][1]))

import sys
from collections import Counter

input = sys.stdin.readline
N = int(input())
V = list(map(int, input().split()))

ans = 0
counter = Counter(V)
if len(counter) == 1:
    ans = N//2
elif N == 2:
    ans = 1
else:
    counter1 = Counter(V[0::2])
    counter2 = Counter(V[1::2])

    counter1 = sorted(counter1.items(), key=lambda x: x[1], reverse=True)
    counter2 = sorted(counter2.items(), key=lambda x: x[1], reverse=True)
    if counter1[0][0] == counter2[0][0]:
        ans = N - counter1[1][1] - counter2[0][1]
        ans = min(ans, N - counter1[0][1] - counter2[1][1])
    else:
        ans = N - counter1[0][1] - counter2[0][1]

print(ans)

from collections import Counter
n = int(input())
vs = list(map(int, input().split()))

eq_lis = []
odd_lis = []
for i in range(n):
    if i %2 ==0:
        eq_lis.append(vs[i])
    else:
        odd_lis.append(vs[i])
        
a = Counter(eq_lis)
b = Counter(odd_lis)
a_val = list(a.values())
b_val = list(b.values())
a_max = max(a_val)
b_max = max(b_val)

a_sorted = sorted(a.items(), key= lambda x:x[1])
b_sorted = sorted(b.items(), key= lambda x:x[1])

if a_sorted[-1][0] == b_sorted[-1][0]:
    if len(a_sorted) == 1 and len(b_sorted) == 1:
        print(n-a_max)
    elif len(a_sorted)==1 and len(b_sorted) >1:
        print(n-a_max-b_sorted[-2][1])
    elif len(a_sorted)>1 and len(b_sorted) ==1:
        print(n-b_max-a_sorted[-2][1])
    else:
        if b_sorted[-2][1] >= a_sorted[-2][1]:
            print(n-a_max-b_sorted[-2][1])
        else:
            print(n-b_max-a_sorted[-2][1])    
else:
    print(n-a_max-b_max)

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

from collections import Counter

def get_counter(X):
  counter = Counter(X)
  X = sorted(list(counter.items()), key = lambda x:x[1], reverse = True)
  X.append((0,0))
  return X

V1 = get_counter(V[::2])
V2 = get_counter(V[1::2])

if V1[0][0] != V2[0][0]:
  print((N - (V1[0][1] + V2[0][1])))
else:
  print((N - max(V1[0][1] + V2[1][1],V1[1][1] + V2[0][1])))


n = int(input())
V = list(map(int, input().split()))
from collections import Counter
even = Counter(V[0::2])
even["0"]=0
even = sorted(even.items(), key=lambda x:x[1], reverse=True)
odd = Counter(V[1::2])
odd["-1"]=0
odd = sorted(odd.items(), key=lambda x:x[1], reverse=True)
i=0
even_top2, odd_top2 = [], []
for (e, o) in zip(even, odd):
  i+=1
  even_top2.append(e)
  odd_top2.append(o)
  if i==2:
    break
if even_top2[0][0] != odd_top2[0][0]:
  notchange = even_top2[0][1] + odd_top2[0][1]
else:
  notchange = max(even_top2[0][1]+odd_top2[1][1], even_top2[1][1]+odd_top2[0][1])
print(n-notchange)

n=int(input())
v=list(map(int,input().split()))
numg=[]
numk=[]
for i in range(n):
    if i%2==0:
        numk.append(v[i])
    else:
        numg.append(v[i])
numk.sort()
numg.sort()
numk2=[]
numg2=[]
num1=0
cnt=0
for i in range(len(numk)):
    if num1!=numk[i]:
        numk2.append([num1,cnt])
        num1=numk[i]
        cnt=1
    else:
        cnt+=1
numk2.append([num1,cnt])
num1=0
cnt=0
for i in range(len(numg)):
    if num1!=numg[i]:
        numg2.append([num1,cnt])
        num1=numg[i]
        cnt=1
    else:
        cnt+=1
numg2.append([num1,cnt])
str1= lambda val: val[1]
numg2.sort(key=str1)
numk2.sort(key=str1)
if numg2[-1][0]==numk2[-1][0]:
    print((n-max(numg2[-1][1]+numk2[-2][1],numg2[-2][1]+numk2[-1][1])))
else:
    print((n-(numg2[-1][1]+numk2[-1][1])))


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

v1_c = Counter(v[::2])
v2_c = Counter(v[1::2])
v1_c = sorted(list(v1_c.items()), key=lambda x: x[1])
v2_c = sorted(list(v2_c.items()), key=lambda x: x[1])

v1 = v1_c
v2 = v2_c

ans_1 = 0

if v1[-1][0]==v2[-1][0]:
    ans_1 += v1[-1][1]
    v1 = v1[:-1]

if len(v1)>=2:
    for i, j in v1[:-1]:
        ans_1 += j

if len(v2)>=2:
    for i, j in v2[:-1]:
        ans_1 += j

v1 = v1_c
v2 = v2_c

ans_2 = 0

if v1[-1][0]==v2[-1][0]:
    ans_2 += v2[-1][1]
    v2 = v2[:-1]

if len(v2)>=2:
    for i, j in v2[:-1]:
        ans_2 += j

if len(v1)>=2:
    for i, j in v1[:-1]:
        ans_2 += j

print(min(ans_1, ans_2))

from collections import *
n = int(input())
v = list(map(int,input().split()))
if len(set(v))==1:
    print(len(v)//2)
    return
n_even = v[0::2]
n_odd = v[1::2]
a = Counter(n_even).most_common()+[(0,0)]
b = Counter(n_odd).most_common()+[(0,0)]
#print(a)
#print(b)
if a[0][0] == b[0][0]:
    ans = min(n-a[0][1]-b[1][1],n-a[1][1]-b[0][1])
else:
    ans = n - a[0][1] - b[0][1]
print(ans)

from collections import Counter
n = int(input())
V = list(map(int, input().split()))
x = len(set(V))
if x == 1:
    print((n // 2))
else:
    A = list()
    B = list()
    for i, v in enumerate(V):
        if i & 1:
            A.append(v)
        else:
            B.append(v)
    A = Counter(A).most_common()
    B = Counter(B).most_common()
    a = A[0]
    b = B[0]
    if a[0] == b[0]:
        if len(A) == 1:
            b = B[1]
        elif len(B) == 1:
            a = A[1]
        else:
            if A[1][1] >= B[1][1]:
                a = A[1]
            else:
                b = B[1]
    print((n - a[1] - b[1]))


import collections

n = int(input())
v = list(map(int, input().split()))
even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))
dict_c_even_bk = dict_c_even.copy()
dict_c_odd_bk = dict_c_odd.copy()

replace_total_tmp = 0
replace_total_tmp2 = 0
max_count_c_odd = max(dict_c_odd.values())
max_count_c_even = max(dict_c_even.values())
max_count_c_even_bk = max_count_c_even
max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]

if len(set(v)) == 1:
    print(int(even_odd_length))
else:    
    if max_c_odd_keys[0] in dict_c_even:
        del dict_c_even[max_c_odd_keys[0]]
    max_count_c_even = max(dict_c_even.values())
    replace_total_tmp = (n - max_count_c_odd - max_count_c_even)
    
    dict_c_even = dict_c_even_bk
    max_count_c_even = max_count_c_even_bk
    
    if max_c_even_keys[0] in dict_c_odd:
        del dict_c_odd[max_c_even_keys[0]]
    max_count_c_odd = max(dict_c_odd.values())
    replace_total_tmp2 = (n - max_count_c_odd - max_count_c_even)
    
    if replace_total_tmp >= replace_total_tmp2:
         replace_total = replace_total_tmp2
    else:
         replace_total = replace_total_tmp
    print(replace_total)

from collections import Counter

n = int(input())
v = list(map(int, input().split()))

even = v[::2]
odd = v[1::2]

c_even = Counter(even)
c_odd = Counter(odd)

e_max1 = [0, 0]
e_max2 = [0, 0]
o_max1 = [0, 0]
o_max2 = [0, 0]

for x, y in list(c_even.items()):
    if y > e_max1[1]:
        e_max2 = e_max1
        e_max1 = [x, y]
    elif y > e_max2[1]:
        e_max2 = [x, y]

for x, y in list(c_odd.items()):
    if y > o_max1[1]:
        o_max2 = o_max1
        o_max1 = [x, y]
    elif y > o_max2[1]:
        o_max2 = [x, y]


if e_max1[0] == o_max1[0]:
    print((min(n - e_max1[1] - o_max2[1], n - e_max2[1] - o_max1[1])))
else:
    print((n - e_max1[1] - o_max1[1]))


from collections import Counter

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

A = Counter(L)
A = sorted(list(A.items()), key=lambda x:x[1], reverse=True)
A.append((-1, 0))

B = Counter(R)
B = sorted(list(B.items()), key=lambda x:x[1], reverse=True)
B.append((-1, 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])))


n = int(input())
V = list(map(int, input().split()))
d={}
for i in range(0,n,2):
    d[V[i]] = d.get(V[i], 0)+1
m1 = 0
o = 0
o2 = 0
for i in d:
    if m1 <= d[i]:
        m1 = d[i]
        o = i
d[o] = 0
m2 = -1
for i in d:
    if m2 <= d[i]:
        m2 = d[i]
        o2 = i
    
d = {}
for i in range(1,n,2):
    d[V[i]] = d.get(V[i], 0)+1
m3 = 0
e = 0
e2 = 0
for i in d:
    if m3 <= d[i]:
        m3 = d[i]
        e = i
d[e] = 0
m4 = -1
for i in d:
    if m4 <= d[i]:
        m4 = d[i]
        e2 = i

if e!=o:
    print(n - m1 - m3)
else:
    print(min(n-m1-m4, n-m2-m3))

import collections

n=int(input())
m=n//2
a=list(map(int,input().split()))
g=[]
k=[]
for x in range(n):
  if (x+1)%2==1:
    k.append(a[x])
  else:
    g.append(a[x])
    
gg=collections.Counter(g)
kk=collections.Counter(k)
aa=collections.Counter(a)

if len(aa)==1:
  print((n//2))
  
else:
  if gg.most_common()[0]==kk.most_common()[0]:
    if len(gg)>1 and len(kk)>1:
      print((min(m-gg.most_common()[0][1]+m-kk.most_common()[1][1],m-kk.most_common()[0][1]+m-gg.most_common()[1][1])))
    elif len(gg)==1:
      print((m-kk.most_common()[1][1]))
    else:
      print((m-gg.most_common()[1][1]))
  else:
    print((n-gg.most_common()[0][1]-kk.most_common()[0][1]))


from collections import Counter
n = int(input())
v = list(map(int, input().split()))
l,r = Counter(v[0::2]).most_common(), Counter(v[1::2]).most_common()
l.append((0,0))
r.append((0,0))
if l[0][0] != r[0][0]:
  print(n-(l[0][1]+r[0][1]))
else:
  print(min(n-(l[1][1]+r[0][1]), n-(l[0][1]+r[1][1])))

import collections

n=int(input())
m=n//2
a=list(map(int,input().split()))
g=[]
k=[]
for x in range(n):
  if (x+1)%2==1:
    k.append(a[x])
  else:
    g.append(a[x])
    
gg=collections.Counter(g)
kk=collections.Counter(k)
aa=collections.Counter(a)

if len(aa)==1:
  print((n//2))
  
else:
  if gg.most_common()[0]==kk.most_common()[0]:
    
      print((min(m-gg.most_common()[0][1]+m-kk.most_common()[1][1],m-kk.most_common()[0][1]+m-gg.most_common()[1][1])))
   
     
  else:
    print((n-gg.most_common()[0][1]-kk.most_common()[0][1]))


import collections
N = int(input())

O = []
E = []
A = list([int(a) for a in input().split(" ")])
for i in range(N):
  if i % 2 == 0:
    E.append(A[i])
  else:
    O.append(A[i])

CE = collections.Counter(E)
CO = collections.Counter(O)
CE2 = CE.most_common(2)
CO2 = CO.most_common(2)
if CE2[0][0] != CO2[0][0]:
  print((len(E) + len(O) - CE2[0][1] - CO2[0][1]))
elif CE2[0][0] == CO2[0][0]:
  if len(CE2) == 1 and len(CO2) == 1:
    print((min([CE2[0][1], CO2[0][1]])))
  elif len(CE2) > 1 and len(CO2) == 1:
    print((len(E) + len(O) - CE2[1][1] - CO2[0][1]))
  elif len(CE2) == 1 and len(CO2) > 1:
    print((len(E) + len(O) - CE2[0][1] - CO2[1][1]))
  elif CE2[0][1] + CO2[1][1] > CO2[0][1] + CE2[1][1]:
    print((len(E) + len(O) - CE2[0][1] - CO2[1][1]))
  elif CE2[0][1] + CO2[1][1] <= CO2[0][1] + CE2[1][1]:
    print((len(E) + len(O) - CE2[1][1] - CO2[0][1]))


from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) <= 1:
    print((int(n/2)))
    return

odd = [v[i] for i in range(0, n, 2)]
odd_val, odd_cnt = list(zip(*Counter(odd).most_common()))

even = [v[i] for i in range(1, n, 2)]
even_val, even_cnt = list(zip(*Counter(even).most_common()))

if even_val[0] != odd_val[0]:
    ans = n-even_cnt[0]-odd_cnt[0]
else:
    if (even_cnt[0] + odd_cnt[1]) >= (even_cnt[1] + odd_cnt[0]):
        ans = n-even_cnt[0]-odd_cnt[1]
    else:
        ans = n-even_cnt[1]-odd_cnt[0]
print(ans)


from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = v[1::2]
b = v[0::2]
a2 = Counter(a)
b2 = Counter(b)

if a2.most_common()[0][0] != b2.most_common()[0][0]:
    print((n-a2.most_common()[0][1]-b2.most_common()[0][1]))
else:
    if len(a2.most_common()) == len(b2.most_common()) == 1:
        print((len(a)-a2.most_common()[0][1]+len(b)))
    elif len(a2.most_common()) == 1:
        if len(b)-b2.most_common()[1][1] >= len(a)+len(b)-b2.most_common()[0][1]:
            print((len(a)+len(b)-b2.most_common()[0][1]))
        else:
            print((len(b)-b2.most_common()[1][1]))
    elif len(b2.most_common()) == 1:
        if len(a)-a2.most_common()[1][1] >= len(a)+len(b)-a2.most_common()[0][1]:
            print((len(a)+len(b)-a2.most_common()[0][1]))
        else:
            print((len(a)-a2.most_common()[1][1]))
    else:
        if len(a)-a2.most_common()[0][1]+len(b)-b2.most_common()[1][1] >= len(a)-a2.most_common()[1][1]+len(b)-b2.most_common()[0][1]:
            print((len(a)-a2.most_common()[1][1]+len(b)-b2.most_common()[0][1]))
        else:
            print((len(a)-a2.most_common()[0][1]+len(b)-b2.most_common()[1][1]))



#!/usr/bin/env python3

#import
#import math
#import numpy as np
n = int(input())
V = list(map(int, input().split()))

even = {0:0}
odd = {0:0}

for i in range(n):
    v = V[i]
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

omax = 0
emax = 0
onext = 0
enext = 0

for e in even:
    if even[e] > even[emax]:
        if even[emax] > even[enext]:
            enext = emax
        emax = e
    elif even[e] > even[enext]:
        enext = e

for o in odd:
    if odd[o] > odd[omax]:
        if odd[omax] > odd[onext]:
            onext = omax
        omax = o
    elif odd[o] > odd[onext]:
        onext = o

if omax != emax:
    print((n - even[emax] - odd[omax]))
else:
    print((n - even[emax] - odd[omax] + min(even[emax] - even[enext], odd[omax] - odd[onext])))


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

from collections import Counter

def get_counter(X):
  counter = Counter(X)
  X = counter.most_common()
  X.append((0,0))
  return X

V1 = get_counter(V[::2])
V2 = get_counter(V[1::2])

if V1[0][0] != V2[0][0]:
  print((N - (V1[0][1] + V2[0][1])))
else:
  print((N - max(V1[0][1] + V2[1][1],V1[1][1] + V2[0][1])))


n=int(input())
a=list(map(int,input().split()))
l1=[0]*100001
l2=[0]*100001
if a.count(a[0])==n:
    print((n//2))
    return

for i in range(0,n,2):
    l1[a[i]]+=1
for i in range(1,n,2):
    l2[a[i]]+=1

x,y=max(l1),max(l2)
#print(x,y)
i_x,i_y=l1.index(x),l2.index(y)
#print(i_x,i_y)

L1=sorted(l1,reverse=True)
L2=sorted(l2,reverse=True)

if i_x == i_y:
    #奇数番目を2番目に多い数でそろえる場合
    ans=min(((n//2-L1[1])+(n//2-L2[0])),((n//2-L1[0])+(n//2-L2[1])))
else:
    ans=((n//2-L1[0])+(n//2-L2[0]))
print(ans)


#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	sample
# CreatedDate:  2020-09-27 14:00:12 +0900
# LastModified: 2020-09-27 14:35:21 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    n = int(input())
    v = list(map(int, input().split()))
    v_even = [v[i] for i in range(0, len(v), 2)]
    v_odd = [v[i] for i in range(1, len(v), 2)]
    even_cnt = sorted(map(list, list(Counter(v_even).items())), key=lambda x: x[1], reverse=True)
    odd_cnt = sorted(map(list, list(Counter(v_odd).items())), key=lambda x: x[1], reverse=True)
    odd_impo = 0
    even_impo = 0
    if len(even_cnt) == 1 and len(odd_cnt) == 1:
        if even_cnt[0][0] == odd_cnt[0][0]:
            if even_cnt[0][1] < odd_cnt[0][1]:
                print((even_cnt[0][1]))
                return

            else:
                print((even_cnt[0][1]))
                return

    if even_cnt[0][0] == odd_cnt[0][0]:
        if even_cnt[0][1] == odd_cnt[0][1]:
            if even_cnt[1][1] < odd_cnt[1][1]:
                odd_impo = 1
                even_impo = 0

            elif even_cnt[1][1] > odd_cnt[1][1]:
                odd_impo = 0
                even_impo = 1

            else:
                odd_impo = 1
                even_impo = 0

        elif even_cnt[0][1] < odd_cnt[0][1]:
            odd_impo = 0
            even_impo = 1

        else:
            odd_impo = 1
            even_impo = 0

    ans = len(v_even) - even_cnt[even_impo][1] + len(v_odd) - odd_cnt[odd_impo][1]

    print(ans)



def __starting_point():
    main()

__starting_point()

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

ans = 0
eve = V[0::2]
odd = V[1::2]
cntEve = collections.Counter(eve)
cntOdd = collections.Counter(odd)

if cntEve.most_common()[0][0] == cntOdd.most_common()[0][0]:
    if len(cntEve) == 1 and len(cntOdd) > 1:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - cntOdd.most_common()[1][1]
    elif len(cntEve) > 1 and len(cntOdd) == 1:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - cntEve.most_common()[1][1]
    elif len(cntEve) == 1 and len(cntOdd) == 1:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1])
    else:
        ans = N - max(cntEve.most_common()[0][1],cntOdd.most_common()[0][1]) - max(cntEve.most_common()[1][1],cntOdd.most_common()[1][1])
else:
    ans = N - int(cntEve.most_common()[0][1]) - int(cntOdd.most_common()[0][1])

print(ans)

n=int(input())

v=list(map(int,input().split()))

lisa=[0 for _ in range(10**5)]
lisb=[0 for _ in range(10**5)]

for i in range(n):
  if i%2==0:
    lisa[v[i]-1]+=1
  else:
    lisb[v[i]-1]+=1

maxnuma=-1
maxnumb=-1

maxa=max(lisa)
maxb=max(lisb)


for i in range(10**5):
  if lisa[i]==maxa:
    maxnuma=i
for i in range(10**5):
  if lisb[i]==maxb:
    maxnumb=i


if maxnuma!=maxnumb:
  print((n-maxa-maxb))
else:
  lisa.sort(reverse=True)
  lisb.sort(reverse=True)
  print((n-max(lisa[0]+lisb[1],lisa[1]+lisb[0])))



import collections

n = int(input())
a = list(map(int,input().split()))
a1 = collections.Counter(a[0::2]).most_common()
a2 = collections.Counter(a[1::2]).most_common()
a1.append((0,0))
a2.append((0,0))
#print(a1)
#print(a2)

if a1[0] != a2[0]:
    print((n-a1[0][1]-a2[0][1]))
else:
    print((min(n-a1[0][1]-a2[1][1],n-a1[1][1]-a2[0][1])))



n = int(input())
al = list(map(int, input().split()))

ol =al[::2]
el =al[1::2]

from collections import Counter
col = Counter(ol)
cel = Counter(el)
scol = sorted(col.items(), key=lambda x: x[1], reverse=True)  
scel = sorted(cel.items(), key=lambda x: x[1], reverse=True)  
scol.append(("x",0))
scel.append(("y",0))


temp = scol[0][1] + scel[0][1]

if scol[0][0]==scel[0][0]:
    temp2 = scol[0][1]+scel[1][1]
    temp3 = scol[1][1]+scel[0][1]
    print(n-max(temp2,temp3))
    
else:
    print(n-temp)

N=int(input())
*V,=map(int,input().split())
import collections

c1=collections.Counter(V[0::2]).most_common()
c2=collections.Counter(V[1::2]).most_common()
c1.append([0,0])
c2.append([0,0])
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

n = int(input())
l = list(map(int, input().split()))
a = {}
b = {}
for i in range(n // 2):
    key_a = l[i * 2]
    key_b = l[i * 2 + 1]
    if key_a in a:
        a[key_a] = a[key_a] + 1
    else:
        a[l[i * 2]] = 1
    if key_b in b:
        b[key_b] = b[key_b] + 1
    else:
        b[key_b] = 1
a = sorted(a.items(), key=lambda x: x[1], reverse=True)
b = sorted(b.items(), key=lambda x: x[1], reverse=True)
# a = list(a.items())
# b = list(b.items())
# print(a)
# print(b)
ca_max = a[0][0]
cb_max = b[0][0]
ca_max_num = a[0][1]
cb_max_num = b[0][1]
same_num = ca_max_num + cb_max_num
if ca_max == cb_max:
    if len(a) > 1:
        next_ca_max = a[1][1]
    else:
        next_ca_max = 0
    if len(b) > 1:
        next_cb_max = b[1][1]
    else:
        next_cb_max = 0
    same_num = max(ca_max_num + next_cb_max, cb_max_num + next_ca_max)
print(n - same_num)

n=int(input())
v=list(map(int,input().split()))
cnt1=[0 for i in range(100001)]
cnt2=[0 for i in range(100001)]
for i in range(n):
    if i%2==0:
        cnt1[v[i]]+=1
    else:
        cnt2[v[i]]+=1
k1=0
k1m=0
k2=0
k2m=0
for i in range(100001):
    if cnt1[i]>=cnt1[k1]:
        k1,k1m=i,k1
    elif cnt1[i]>cnt1[k1m]:
        k1m=i
for i in range(100001):
    if cnt2[i]>=cnt2[k2]:
        k2,k2m=i,k2
    elif cnt2[i]>cnt2[k2m]:
        k2m=i
if k1!=k2:
    print((n-cnt1[k1]-cnt2[k2]))
else:
    print((n-(cnt1[k1]+max(cnt1[k1m],cnt2[k2m]))))


from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = Counter(v[::2])
b = Counter(v[1::2])
a = a.most_common()
b = b.most_common()
a1 = a[0][1]
b1 = b[0][1]
if len(a) == 1:
    a2 = 0
else:
    a2 = a[1][1]
if len(b) == 1:
    b2 = 0
else:
    b2 = b[1][1]
if a[0][0] != b[0][0]:
    print(n-(a1+b1))
else:
    print(min(n-(a1+b2),n-(a2+b1)))

from collections import Counter
n = int(input())
ls = list(map(int,input().split()))
lso = ls[::2]
lse = ls[1::2]
lso.sort()
lse.sort(reverse=True)
co = Counter(lso)
ce = Counter(lse)
co1,co2 = co.most_common()[0][0],co.most_common()[0][1]
ce1,ce2 = ce.most_common()[0][0],ce.most_common()[0][1]
coo1,coo2,cee1,cee2 = 0,0,0,0
if co2 != n//2:
    coo1,coo2 = co.most_common()[1][0],co.most_common()[1][1]
if ce2 != n//2:
    cee1,cee2 = ce.most_common()[1][0],ce.most_common()[1][1]
if co1 == ce1:
    print(n-max(co2+cee2,ce2+coo2))
else:
    print(n-co2-ce2)

def find_max( list ):
    x = 0
    x2 = 0
    x_i = 0
    x2_i = 0
    for i in range( len(list) ):
        if x < list[i]:
            x = list[i]
            x_i = i
    for i in range( len(list) ):
        if i == x_i:
            continue
        if x2 < list[i] <= x:
            x2 = list[i]
            x2_i = i
    return x,x2,x_i,x2_i

n = int( input() )
v = list ( int(x) for x in input().split() )

v_sort = sorted( v )

v_odd = [ 0 for i in range( v_sort[-1] + 1 ) ]
#奇数
v_eve = [ 0 for i in range( v_sort[-1] + 1 ) ]
#偶数
for i in range( n ):
    if i % 2 == 0:
        v_eve[ v[i] ] += 1
    if i % 2 == 1:
        v_odd[ v[i] ] += 1

vex,vex2,vex_i,vex2_i = find_max( v_eve )
vox,vox2,vox_i,vox2_i = find_max( v_odd )

ok = 0
# ok: figure that need not to fix
if vex_i != vox_i:
    ok = vex + vox
else:
    ok = max( vex + vox2 , vex2 + vox )

ans = n - ok
print( ans )

n=int(input())
v=list(map(int,input().split()))
import collections as col
o=col.Counter(v[0:n:2])
e=col.Counter(v[1:n:2])
ook=o.most_common()
eok=e.most_common()
ok=ook[0][1]+eok[0][1]
if ook[0][0]==eok[0][0]:
    if len(ook)<2 and len(eok)<2:
        print(n//2)
        return
    elif len(ook)<2:
        ok=ook[0][1]+eok[1][1]
    elif len(eok)<2:
        ok=ook[1][1]+eok[0][1]
    else:
        ok=max(ook[0][1]+eok[1][1],ook[1][1]+eok[0][1])
print(n-ok)

import collections
N = int(input())
N_List = list(map(int,input().split()))
hanN = N//2
ki = N_List[1::2]
gu = N_List[0::2]
kicnt = collections.Counter(ki)
gucnt = collections.Counter(gu)

kidict = kicnt.most_common()
gudict = gucnt.most_common()

kilen = len(kidict)
gulen = len(gudict)

if kilen == 1 & gulen == 1:
    if kidict == gudict:
        ans = hanN
    else:
        ans = 0
elif kidict[0][0] == gudict[0][0]:
    if kidict[0][1] > gudict[0][1]:
        ans = sum(map(lambda x:x[1],kidict[1:])) + sum(map(lambda x:x[1],gudict[2:])) + gudict[0][1]
    elif kidict[0][1] < gudict[0][1]:
        ans = sum(map(lambda x:x[1],gudict[1:])) + sum(map(lambda x:x[1],kidict[2:])) + kidict[0][1]
    else:
        if gudict[1][1] >= kidict[1][1]:
            ans = sum(map(lambda x:x[1],kidict[1:])) + sum(map(lambda x:x[1],gudict[2:])) + gudict[0][1]
        else:
            ans = sum(map(lambda x:x[1],gudict[1:])) + sum(map(lambda x:x[1],kidict[2:])) + kidict[0][1]
else:
    ans = sum(map(lambda x:x[1],gudict[1:])) + sum(map(lambda x:x[1],kidict[1:]))

print(ans)

import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1

la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = 0
    cntb[ib] = 0

if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
else:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)


# -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 20:29:30 2020

@author: liang
"""

n = int(input())
E = list()
O = list()
i = 0
for v in input().split():
    if i%2 == 0:
        E.append(int(v))
    else:
        O.append(int(v))
    i += 1
#print(E)
#print(O)
edic = {-1:0}
odic = {-1:0}
for e in E:
    if e not in edic.keys():
        edic[e] = 1
    else:
        edic[e] += 1

for o in O:
    if o not in odic.keys():
        odic[o] = 1
    else:
        odic[o] += 1

etup = list()
otup = list()
for e in edic.keys():
    etup.append((e,edic[e]))
for o in odic.keys():
    otup.append((o,odic[o]))    
etup.sort(reverse=True,key=lambda x:x[1])
otup.sort(reverse=True,key=lambda x:x[1])

#print(etup)
#print(otup)
i = 0
j = 0
while True:
    ekey, etmp = etup[i]
    okey, otmp = otup[j]
    if ekey != okey:
        break
    if etup[i+1][1] < otup[j+1][1]:
        j += 1
    else:
        i += 1
    #rint("calc")

#print(edic)

ans = n - etmp - otmp
    
print(ans)

from collections import Counter
n = int(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]) #最頻値が異なる場合は、全体の数からそれぞれの最頻値の数を引く

import collections
n = int(input())
a = [int(x) for x in input().split()]
even = []
uneven = []
for i in range(n):
  if i%2 == 0:
    uneven.append(a[i])
    continue
  even.append(a[i])

uneven_counter = collections.Counter(uneven)
sortede_uneven_counter = sorted(uneven_counter.items(),key=lambda x:x[1],reverse=True)
even_counter = collections.Counter(even)
sortede_even_counter = sorted(even_counter.items(),key=lambda x:x[1],reverse=True)
  
ans = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[0][1])

if sortede_uneven_counter[0][0] == sortede_even_counter[0][0]:
  if len(set(a)) == 1:
    ans = n/2
  elif sortede_uneven_counter[0][0] ==sortede_even_counter[0][0]:
    ans = (n/2 - sortede_uneven_counter[1][1]) + (n/2 - sortede_even_counter[0][1])
    ans2 = (n/2 - sortede_uneven_counter[0][1]) + (n/2 - sortede_even_counter[1][1])
    if ans2<ans:
      ans = ans2

print(int(ans))

n=int(input())
l=list(map(int, input().split()))
l1=l[0::2]
l2=l[1::2]
import collections
c1 = collections.Counter(l1)
#print(c1)
# Counter({'a': 4, 'c': 2, 'b': 1})
c2 =collections.Counter(l2)  
c0 =collections.Counter(l)
if len(c0)==1:
  print((int(n/2)))
else:
  if c1.most_common()[0]==c2.most_common()[0]:
    print((min(n-c1.most_common()[0][1]-c2.most_common()[1][1], n-c1.most_common()[1][1]-c2.most_common()[0][1])))
  else:
    print((n-c1.most_common()[0][1]-c2.most_common()[0][1]))
    


from collections import Counter
def main():
    N = int(input())
    V = [int(a) for a in input().split()]
    
    even = list()
    odd = list()

    for i in range(N):
        if (i + 1) % 2 == 0:
            odd.append(V[i])
        else:
            even.append(V[i])

    even_counter = Counter(even).most_common()
    odd_counter = Counter(odd).most_common()

    ans = 0
    if even_counter[0][0] != odd_counter[0][0]:
        if len(even_counter) >= 2:
            ans += len(even) - even_counter[0][1]

        if len(odd_counter) >= 2:
            ans += len(odd) - odd_counter[0][1]

    else:
        if len(even_counter) == 1 and len(odd_counter) == 1:
            ans += even_counter[0][1]

        elif len(even_counter) == 1 and len(odd_counter) >= 2:
            ans += len(odd) - odd_counter[1][1]

        elif len(even_counter) >= 2  and len(odd_counter) == 1:
            ans += len(even) - even_counter[1][1]

        elif len(even_counter) >= 2 and len(odd_counter) >= 2:
            cost_even = len(even) - even_counter[0][1] + len(odd)  - odd_counter[1][1]
            cost_odd  = len(odd)  - odd_counter[0][1]  + len(even) - even_counter[1][1]

            ans += min(cost_even, cost_odd)

    print(ans)

def __starting_point():
    main()
__starting_point()

import collections
url = "https://atcoder.jp//contests/abc111/tasks/arc103_a"

def main():
    input()
    t = list(map(int, input().split()))
    even_lis = t[::2]
    odd_lis = t[1::2]
    e = collections.Counter(even_lis).most_common()
    odd = collections.Counter(odd_lis).most_common()
    if e[0][0] == odd[0][0]:
        if e[0][1] + odd[0][1] == len(t):
            print((e[0][1]))
            return
        else:
            print((len(t) - max(e[0][1], odd[0][1]) - max(e[1][1], odd[1][1])))
            return
    else:
        print((len(t) - e[0][1] - odd[0][1]))


def __starting_point():
    main()

__starting_point()

n = int(input())
v = list(map(int, input().split()))
odd = dict()
even = dict()
odd[-1] = 0
even[-1] = 0

for i in range(n):
    if (i + 1) % 2 == 1:
        if v[i] not in odd:
            odd[v[i]] = 1
        else:
            odd[v[i]] += 1
    else:
        if v[i] not in even:
            even[v[i]] = 1
        else:
            even[v[i]] += 1

odd_values = sorted(list(odd.values()), reverse=True)
for key, val in list(odd.items()):
    if val == odd_values[0]:
        odd_1 = key
    elif val == odd_values[1]:
        odd_2 = key

even_values = sorted(list(even.values()), reverse=True)
for key, val in list(even.items()):
    if val == even_values[0]:
        even_1 = key
    elif val == even_values[1]:
        even_2 = key

if odd_1 != even_1:
    res = n - odd_values[0] - even_values[0]
else:
    res = min(n - odd_values[0] - even_values[1], 
              n - odd_values[1] - even_values[0])
print(res)
# print(odd)
# print(even)


import sys
from collections import Counter


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return list(map(int, stdin.readline().split()))
def nl(): return list(map(int, stdin.readline().split()))


def get_ans(v, ans):
    while len(v) != 1:
        ans += v.pop()
    return ans


def main():
    n = ni()
    V = nl()
    V_e = V[0::2]
    V_o = V[1::2]
    V_e_c = Counter(V_e)
    V_o_c = Counter(V_o)
    # num_V_e = sorted(list(V_e_c.values()))[::-1]
    # num_V_o = sorted(list(V_o_c.values()))[::-1]

    if V_e_c.most_common()[0][0] != V_o_c.most_common()[0][0]:
        ans = len(V) - \
            V_e_c.most_common()[0][1] - V_o_c.most_common()[0][1]

    else:
        if len(V_e_c.most_common()) == 1 or len(V_o_c.most_common()) == 1:
            if len(V_e_c.most_common()) == 1 and len(V_o_c.most_common()) == 1:
                ans = len(V) // 2
            else:
                if len(V_e_c.most_common()) != 1:
                    ans = len(V) // 2 - V_e_c.most_common()[1][1]
                else:
                    ans = len(V) // 2 - V_o_c.most_common()[1][1]

        else:
            ans = len(V) - max(
                V_e_c.most_common()[0][1] + V_o_c.most_common()[1][1],
                V_e_c.most_common()[1][1] + V_o_c.most_common()[0][1],
            )

    print(ans)


def __starting_point():
    main()

__starting_point()

N = int(input())
V = list(map(int, input().split()))
odd_dict = {}
even_dict = {}
for i in range(N):
    if i % 2 == 0:
        if odd_dict.get(V[i]) is None:
            odd_dict[V[i]] = 1
        else:
            odd_dict[V[i]] += 1
    else:
        if even_dict.get(V[i]) is None:
            even_dict[V[i]] = 1
        else:
            even_dict[V[i]] += 1

odd_dict_sorted = sorted(list(odd_dict.items()), key=lambda a: a[1])
even_dict_sorted = sorted(list(even_dict.items()), key=lambda a: a[1])

odd_dict_max = odd_dict_sorted.pop()
even_dict_max = even_dict_sorted.pop()
if odd_dict_max[0] == even_dict_max[0] and N // 2 == odd_dict_max[1]:
    ans = N // 2
elif odd_dict_max[0] == even_dict_max[0]:
    odd_dict_max_t = odd_dict_sorted.pop()
    even_dict_max_t = even_dict_sorted.pop()
    ans = N - odd_dict_max[1] - max(even_dict_max_t[1],odd_dict_max_t[1])
else:
    ans = N - odd_dict_max[1] - even_dict_max[1]
print(ans)


from collections import Counter
def main():
    N = int(input())
    V = [int(a) for a in input().split()]
    
    even = list()
    odd = list()

    for i in range(N):
        if (i + 1) % 2 == 0:
            odd.append(V[i])
        else:
            even.append(V[i])

    even_counter = Counter(even).most_common()
    odd_counter = Counter(odd).most_common()

    ans = 0
    if even_counter[0][0] != odd_counter[0][0]:
        if len(even_counter) >= 2:
            ans += len(even) - even_counter[0][1]

        if len(odd_counter) >= 2:
            ans += len(odd) - odd_counter[0][1]

    else:
        if len(even_counter) == 1 and len(odd_counter) == 1:
            ans += even_counter[0][1]

        elif len(even_counter) == 1 and len(odd_counter) >= 2:
            ans += len(odd) - odd_counter[1][1]

        elif len(even_counter) >= 2  and len(odd_counter) == 1:
            ans += len(even) - even_counter[1][1]

        elif len(even_counter) >= 2 and len(odd_counter) >= 2:
            cost_even = len(even) - even_counter[0][1] + len(odd)  - odd_counter[1][1]
            cost_odd  = len(odd)  - odd_counter[0][1]  + len(even) - even_counter[1][1]
            ans += min(cost_even, cost_odd)

    print(ans)

def __starting_point():
    main()
__starting_point()

from collections import Counter
n = int(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])

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

v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1 = sorted(list(v1.items()), key=lambda x: x[1])
v2 = sorted(list(v2.items()), key=lambda x: x[1])

ans_1 = 0

if v1[-1][0]==v2[-1][0]:
    ans_1 += v1[-1][1]
    v1 = v1[:-1]

if len(v1)>=2:
    for i, j in v1[:-1]:
        ans_1 += j

if len(v2)>=2:
    for i, j in v2[:-1]:
        ans_1 += j

v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1 = sorted(list(v1.items()), key=lambda x: x[1])
v2 = sorted(list(v2.items()), key=lambda x: x[1])

ans_2 = 0

if v1[-1][0]==v2[-1][0]:
    ans_2 += v2[-1][1]
    v2 = v2[:-1]

if len(v2)>=2:
    for i, j in v2[:-1]:
        ans_2 += j

if len(v1)>=2:
    for i, j in v1[:-1]:
        ans_2 += j

print(min(ans_1, ans_2))

import sys, bisect, math, itertools, string, queue, copy
#import numpy as np
#import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return list(map(int,input().split()))
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
a = inpl()

cnt_even = Counter(a[::2]).most_common()+[(0,0)]
cnt_odd = Counter(a[1::2]).most_common()+[(0,0)]

ans = 0
if cnt_even[0][0] == cnt_odd[0][0]:
  ans = n - max(cnt_even[0][1],cnt_odd[0][1]) - max(cnt_even[1][1],cnt_odd[1][1])
else:
  ans = n - cnt_even[0][1] - cnt_odd[0][1]

print(ans)


import sys
from collections import Counter
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    n, *V = list(map(int, read().split()))

    counter1 = Counter(V[::2])
    counter2 = Counter(V[1::2])

    vec1 = sorted(list(counter1.items()), reverse=True, key=itemgetter(1))
    vec2 = sorted(list(counter2.items()), reverse=True, key=itemgetter(1))

    if vec1[0][0] != vec2[0][0]:
        ans = n - vec1[0][1] - vec2[0][1]
    elif len(vec1) == len(vec2) == 1:
        ans = n // 2
    else:
        tmp = []
        if len(vec1) > 1:
            tmp.append(vec1[1][1] + vec2[0][1])
        if len(vec2) > 1:
            tmp.append(vec1[0][1] + vec2[1][1])
        ans = n - max(tmp)

    print(ans)

    return


def __starting_point():
    main()

__starting_point()

from  collections import Counter

n = int(input())
v = list(map(int, input().split()))

c = Counter(v[::2])
d = Counter(v[1::2])

x = c.most_common()
y = d.most_common()

s = 0

if x[0][0] == y[0][0]:
    if len(x) > 1 and len(y) > 1:
        s = min(n - x[0][1] - y[1][1], n - x[1][1] - y[0][1])
    elif len(x) > 1:
        s = n - x[1][1] - y[0][1]
    elif len(y) > 1:
        s = n - x[0][1] - y[1][1]
    else:
        s = n // 2
else:
    s = n - x[0][1] - y[0][1]

print(s)

n = int(input())
v = list(map(int,input().split()))

v1 = [v[i] for i in range(n) if i%2 == 1]
v2 = [v[i] for i in range(n) if i%2 == 0]
            
import collections

v1n = collections.Counter(v1)
v2n = collections.Counter(v2)

v1ns = v1n.most_common(2)
v2ns = v2n.most_common(2)

a = v2ns[0][1]
c = v1ns[0][1]
if v1ns[0][0]!=v2ns[0][0]:
    print(n-a-c)
else:
    if len(v1ns)==1:
        d = 0
    else:
        d = v1ns[1][1]
    if len(v2ns)==1:
        b = 0
    else:
        b = v2ns[1][1]
    print(min(n-a-d,n-c-b))

import collections
n = int(input())
v = list(map(int, input().split()))
even = [v[2*i] for i in range(n//2)]
odd = [v[2*i+1] for i in range(n//2)]
dEven = collections.Counter(even).most_common()
dOdd = collections.Counter(odd).most_common()
if dEven[0][0] != dOdd[0][0]:
    ans = n - dEven[0][1]  - dOdd[0][1]
else:
    if len(dEven) >=2 and len(dOdd) >= 2:
        ans = n - max(dEven[0][1]+dOdd[1][1], dEven[1][1]+dOdd[0][1])
    elif len(dEven) < len(dOdd):
        ans = n - (dEven[0][1]+dOdd[1][1])
    elif len(dEven) > len(dOdd):
        ans = n - (dEven[1][1]+dOdd[0][1])
    else:
        ans = n//2
print(ans)

from collections import Counter
n = int(input())
v_lis = list(map(int,input().split()))

v_odd = [0] * (n // 2)
v_even = [0] * (n // 2)

for i in range(n):
  if (i + 1) % 2 == 1:
    v_odd[i//2] += v_lis[i]
  else:
    v_even[i//2] += v_lis[i]
    
v_odd, v_even = Counter(v_odd).most_common(), Counter(v_even).most_common()

if v_odd[0][0] != v_even[0][0]:
  cnt = v_odd[0][1] + v_even[0][1]

else:
  tmp1 = v_odd[0][1] + (v_even[1][1] if len(v_even) >= 2 else 0)
  tmp2 = v_even[0][1] + (v_odd[1][1] if len(v_odd) >= 2 else 0)
  cnt = max(tmp1, tmp2)

print(n - cnt)

#!/usr/bin/env python3
from collections import Counter
# from numba import njit

# input = stdin.readline

# @njit
def solve(n,v):
  if all(x == v[0] for x in v):
    return n//2
  v_even = v[::2]
  v_odd  = v[1::2]

  d_even = list(sorted(list(Counter(v_even).items()),key=lambda x: x[1],reverse=True))
  d_odd  = list(sorted(list(Counter(v_odd).items()),key=lambda x: x[1],reverse=True))
  e0 = d_even[0]
  o0 = d_odd[0]
  if e0[0] != o0[0]:
    return n - e0[1] - o0[1]
  e1 = d_even[1]
  o1 = d_odd[1]
  return min(n-e0[1]-o1[1],n-e1[1]-o0[1])



def main():
  N = int(input())
  # N,M = map(int,input().split())
  v = list(map(int,input().split()))
  print((solve(N,v)))
  return

def __starting_point():
  main()

__starting_point()

from collections import defaultdict
ODD = defaultdict(int)
EVEN = defaultdict(int)
ALL = set([])
N = int(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)
  return
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)




from collections import Counter
n=int(input())
a=list(map(int,input().split()))

f=Counter(a[0::2]).most_common(2)
b=Counter(a[1::2]).most_common(2)

if f[0][0]!=b[0][0]:print(n-f[0][1]-b[0][1]);return

if f[0][1]==n//2:print(n//2)
else:print(n-b[0][1]-f[1][1] if f[1][1]>b[1][1] else n-f[0][1]-b[1][1])

N=int(input())
*V,=map(int,input().split())
from collections import Counter

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

n=int(input())
a=[int(i) for i in input().split()]

one=[]
two=[]

for i in range(n):
    if i%2==0:
        one.append(a[i])
    else:
        two.append(a[i])

one_count=[0]*(10**5+1)
two_count=[0]*(10**5+1)

for i in one:
    one_count[i]+=1
for i in two:
    two_count[i]+=1

one_first_index=0
one_max_count=0
for i,value in enumerate(one_count):
    if one_max_count<value:
        one_max_count=value
        one_first_index=i
one_second_index=0
one_second_max_count=0
for i,value in enumerate(one_count):
    if one_second_max_count<value and i!=one_first_index:
        one_second_max_count=value
        one_second_index=i

two_first_index=0
two_max_count=0
for i,value in enumerate(two_count):
    if two_max_count<value:
        two_max_count=value
        two_first_index=i
two_second_index=0
two_second_max_count=0
for i,value in enumerate(two_count):
    if two_second_max_count<value and i!=two_first_index:
        two_second_max_count=value
        two_second_index=i



if one_first_index!=two_first_index:
    print((n-one_max_count-two_max_count))
elif one_max_count-one_second_max_count<=two_max_count-two_second_max_count:
    print((n - one_second_max_count - two_max_count))
else:
    print((n - two_second_max_count - one_max_count))





#!/usr/bin/env python3
from collections import Counter

n, *v = list(map(int, open(0).read().split()))
odd = [v[i] for i in range(0, n, 2)]
even = [v[i] for i in range(1, n, 2)]
o = Counter(odd)
e = Counter(even)

if o.most_common()[0][0] != e.most_common()[0][0]:
    print((n - o.most_common()[0][1] - e.most_common()[0][1]))
else:
    a = n - o.most_common()[0][1] - max(sorted(e.values())[:-1] + [0])
    b = n - e.most_common()[0][1] - max(sorted(o.values())[:-1] + [0])
    print((min(a, b)))


import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def get_primenumber(number):#素数列挙
    prime_list = []
    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
    while search_list[0] <= math.sqrt(number):
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list = [num for num in search_list if num % head_num != 0]
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list
def factrization_prime(number):#素因数分解
    factor = {}
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor[div] = div_cnt
        div += 1
    if number > 1:
        factor[number] = 1
    return factor
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
num = []
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
V = l()

odd = [i for i in V[::2]]
even = [i for i in V[1::2]]

O = Counter(odd).most_common()
E = Counter(even).most_common()
a = len(V)//2

if O[0][0] == E[0][0]:
    if O[0][1] == a:
        print(a)
    else:
        print(min((a-O[0][1])+(a-E[1][1]), (a-O[1][1])+(a-E[0][1])))
else:
    print((a-O[0][1])+(a-E[0][1]))

import collections

n = int(input())
v = list(map(int, input().split()))
even_odd_length = n / 2
replace_total = 0

list_odd = v[0::2]
list_even = v[1::2]

dict_c_odd = dict(collections.Counter(list_odd))
dict_c_even = dict(collections.Counter(list_even))
dict_c_even_bk = dict_c_even.copy()

replace_total_tmp = 0
replace_total_tmp2 = 0

max_count_c_odd = max(dict_c_odd.values())
max_count_c_even = max(dict_c_even.values())
max_count_c_even_bk = max_count_c_even

max_c_odd_keys = [k for k, v in dict_c_odd.items() if v == max_count_c_odd]
max_c_even_keys = [k for k, v in dict_c_even.items() if v == max_count_c_even]

if len(set(v)) == 1:
    print(int(even_odd_length))
else:    
    if max_c_odd_keys[0] in dict_c_even:
        del dict_c_even[max_c_odd_keys[0]]
    max_count_c_even = max(dict_c_even.values())
    replace_total_tmp = (n - max_count_c_odd - max_count_c_even)
    
    dict_c_even = dict_c_even_bk
    max_count_c_even = max_count_c_even_bk
    
    if max_c_even_keys[0] in dict_c_odd:
        del dict_c_odd[max_c_even_keys[0]]
    max_count_c_odd = max(dict_c_odd.values())
    replace_total_tmp2 = (n - max_count_c_odd - max_count_c_even)
    
    if replace_total_tmp >= replace_total_tmp2:
         replace_total = replace_total_tmp2
    else:
         replace_total = replace_total_tmp

    print(replace_total)

n = int(input())
a = list(map(int, input().split()))
a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c = Counter(a1)
c1 = []
for i in c:
    c1.append([c[i],i])
c1.sort(reverse = True)

c = Counter(a2)
c2 = []
for i in c:
    c2.append([c[i],i])
c2.sort(reverse = True)

ans = n
if c1[0][1] != c2[0][1]:
    ans -= c1[0][0]
    ans -= c2[0][0]
else:
    buf1 = 0
    buf1 += c1[0][0]
    if len(c2) > 1: buf1 += c2[1][0]
    buf2 = 0
    buf2 += c2[0][0]
    if len(c1) > 1: buf2 += c1[1][0]
    ans -= max(buf1,buf2)
print(ans)

import collections as co
def __starting_point():

	n = int(input())
	A = list(map(int,input().split()))

	S = A[1::2]
	T = A[0::2]

	total_cnt = 0

	#全体をチェック
	U = set(A)
	if len(U) == 1:
		total_cnt = len(A[1::2])
		print(total_cnt)
		return

	c1 = []
	c2 = []
	#奇数列をチェック
	s = co.Counter(S)
	c1 = s.most_common()
	#これが秘策
	c1.append((0,0))
	#偶数列をチェック
	t = co.Counter(T)
	c2 = t.most_common()
	#これが秘策
	c2.append((0,0))


	#チェック
	#最頻値が異なるなら
	if c1[0][0] != c2[0][0]:
		#それ以外の数を総カウント-1
		total_cnt = len(S) - c1[0][1] 
		total_cnt += len(T) - c2[0][1]
	else:
		#最頻値が同じならその数が同じか？
		if c1[0][1] > c2[0][1]:
			total_cnt = len(S) - c1[0][1]
			total_cnt += len(T) - c2[1][1]
		elif c1[0][1] < c2[0][1]:
			total_cnt = len(S) - c1[1][1]
			total_cnt += len(T) - c2[0][1]
		else:
			#同じ場合、２番目の数値を比較して取り換え
			if c1[1][1] > c2[0][1]:
				total_cnt = len(S) - c1[1][1]
				total_cnt += len(T) - c2[0][1]
			elif c1[1][1] < c2[1][1]:
				total_cnt = len(T) - c2[1][1]
				total_cnt += len(S) - c1[0][1]
			else:
				#どちらでもよい
				total_cnt = len(S) - c1[1][1]
				total_cnt += len(T) - c2[0][1]
				
	print(total_cnt)


__starting_point()

from collections import Counter

n = int(input())
V = list(map(int, input().split()))

e = Counter(V[0::2]).most_common()
o = Counter(V[1::2]).most_common()
e.append((0, 0))
o.append((0, 0))
res = 0

if(e[0][0] == o[0][0]):
    print((min(n - o[0][1] - e[1][1], n - o[1][1] - e[0][1])))
else:
    print((n - o[0][1] - e[0][1]))


from collections import Counter

n = int(input())
A = list(map(int, input().split()))

kisu = A[0::2]
gusu = A[1::2]

CK = Counter(kisu)
CG = Counter(gusu)
CKM = CK.most_common(2)
CGM = CG.most_common(2)

if len(CKM) == 1 and len(CGM) == 1:
    if CKM[0][0] == CGM[0][0]:
        ans = n // 2
    else:
        ans = 0
elif len(CKM) == 1:
    if CKM[0][0] == CGM[0][0]:
        ans = n // 2 - CGM[1][1]
    else:
        ans = n // 2 - CGM[0][1]
elif len(CGM) == 1:
    if CKM[0][0] == CGM[0][0]:
        ans = n // 2 - CKM[1][1]
    else:
        ans = n // 2 - CKM[0][1]
else:
    if CKM[0][0] == CGM[0][0]:
        ans1 = n // 2 - CKM[1][1] + n // 2 - CGM[0][1]
        ans2 = n // 2 - CGM[1][1] + n // 2 - CKM[0][1]
        ans = min(ans1, ans2)
    else:
        ans = n - (CKM[0][1] + CGM[0][1])

print(ans)



from collections import Counter


def resolve():
    N = int(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))


def __starting_point():
    resolve()

__starting_point()

import sys, bisect, math, itertools, string, queue, copy
#import numpy as np
#import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return list(map(int,input().split()))
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
a = inpl()

cnt_even = defaultdict(int)
cnt_odd = defaultdict(int)
for i in range(0,n,2):
  cnt_even[a[i]] += 1
for i in range(1,n,2):
  cnt_odd[a[i]] += 1

cnt_even = list(reversed(sorted(list(cnt_even.items()),key=lambda x:x[1])))
cnt_odd  = list(reversed(sorted(list(cnt_odd.items()),key=lambda x:x[1])))

flg = False
for i in range(min(2,len(cnt_even),len(cnt_odd))):
  a,b = (cnt_even[i],cnt_odd[i])
  if a[0] != b[0]:
    if flg == False:
      n -= a[1]+b[1]
    else:
      n -= max(a[1],b[1])
    break
  else:
    n -= a[1]
    flg = True

print(n)


n = int(input())
v = list(map(int, input().split()))
v1 = v[0::2]
v2 = v[1::2]

from collections import Counter
c1 = list(Counter(v1).items())
c2 = list(Counter(v2).items())

c1 = sorted(c1, key= lambda x: x[1], reverse= True)
c2 = sorted(c2, key= lambda x: x[1], reverse= True)

c1.append((0,0))
c2.append((0,0))

#print(c1[:3], c2[:3])
if c1[0][0] != c2[0][0]:
    print(n - c1[0][1] - c2[0][1])
else:
    a = c1[0][1] + c2[1][1]
    b = c1[1][1] + c2[0][1]
    if a < b:
        print(n - b)
    else:
        print(n - a)

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

    tmp = 0
    dic1 = {}
    dic2 = {}

    for i in range(n):
        if i % 2 == 0:
            if inlis[i] in dic1:
                dic1[inlis[i]] += 1
            else:
                dic1[inlis[i]] = 1
        else:
            if inlis[i] in dic2:
                dic2[inlis[i]] += 1
            else:
                dic2[inlis[i]] = 1
    diclis1 = list(dic1.items())
    diclis2 = list(dic2.items())

    diclis1 = sorted(diclis1, key = lambda x:x[1], reverse=True)
    diclis2 = sorted(diclis2, key = lambda x:x[1], reverse=True)

    key1, val1 = diclis1[0][0], diclis1[0][1]
    key2, val2 = diclis2[0][0], diclis2[0][1]
    

    if key1 != key2:
        print((n- val1 - val2))
    else:
        #print(diclis1, diclis2, len(diclis1))
        if len(diclis1) > 1 and len(diclis2) > 1:
            ans = min(n-diclis1[0][1]-diclis2[1][1], n-diclis1[1][1]-diclis2[0][1])
        
        elif len(diclis2) > 1:
            ans = min(n//2 + n//2 - diclis2[1][1], n/2 - diclis2[0][1])
        elif len(diclis1) > 1:
            ans = min(n//2 + n//2 - diclis1[1][1], n/2 - diclis1[0][1])
        else:
            ans = n//2


        print(ans)
    

def __starting_point():
    main()

__starting_point()

n = int(input())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1).most_common()
dic2 = Counter(list2).most_common()
dic1.append([0,0])
dic2.append([0,0])
if dic1[0][0]!=dic2[0][0]:
  print(n - dic1[0][1] - dic2[0][1])
else:
  print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[0][1]))

n=int(input())
v=list(input().split())
v0={}
v1={}
for i in range(0,n,2):
    if v[i] in v0:
        v0[v[i]]+=1
    else:
        v0[v[i]]=1
for i in range(1,n,2):
    if v[i] in v1:
        v1[v[i]]+=1
    else:
        v1[v[i]]=1
v0=sorted(v0.items(), key=lambda x:x[1], reverse=True)
v1=sorted(v1.items(), key=lambda x:x[1], reverse=True)
if v0[0][0]==v1[0][0]:
    if len(v0)==1:
        print(int(n/2))
    else:
        print(n-v0[0][1]-(v0[1][1] if v0[1][1]>v1[1][1] else v1[1][1] ))
else:
    print(n-v0[0][1]-v1[0][1])

n = int(input())
alist  = list(map(int,input().split()))
list1 = alist[1::2]
list2 = alist[0::2]
from collections import Counter
dic1 = Counter(list1).most_common()
dic2 = Counter(list2).most_common()
dic1.append([0,0])
dic2.append([0,0])
if dic1[0][0]!=dic2[0][0]:
  print(n - dic1[0][1] - dic2[0][1])
else:
  print(min(n - dic1[0][1] - dic2[1][1], n -dic1[1][1] - dic2[0][1]))

from collections import Counter
def solve():
  ans = 0
  N = int(input())
  V = list(map(int, input().split()))
  V1 = [V[i] for i in range(0,N,2)]
  V2 = [V[i] for i in range(1,N,2)]
  v1 = Counter(V1)
  v2 = Counter(V2)
  v1 = sorted(v1.items(),key=lambda x:-x[1])
  v2 = sorted(v2.items(),key=lambda x:-x[1])
  if v1[0][0]!=v2[0][0]:
    ans = N-(v1[0][1]+v2[0][1])
  else:
    if len(v1)==1:
      if len(v2)==1:
        return N//2
      return N-(v1[0][1]+v2[1][1])
    if len(v2)==1:
      return N-(v1[1][1]+v2[0][1])
    ans = N-max(v1[1][1]+v2[0][1],v1[0][1]+v2[1][1])
  return ans
print(solve())

from collections import Counter
import sys
n = int(input())
v = [[], []]
for i, j in enumerate(input().split()):
    if i & 1:
        v[0].append(int(j))
    else:
        v[1].append(int(j))

v1, v2 = Counter(v[0]), Counter(v[1])
mx1 , mx2 = v1.most_common()[0], v2.most_common()[0]
if mx1[0] == mx2[0]:
    if mx1[1] + mx2[1] == n:
        print((n//2))
        return 
    nx1, nx2 = v1.most_common()[1][1], v2.most_common()[1][1]# 次に最も多い数
    if nx1 > nx2:
        print((n - nx1 - mx2[1]))
    else:
        print((n - mx1[1] - nx2))
else:
    print((n - mx1[1] - mx2[1]))
    


from collections import Counter
N=int(input())
v=list(map(int,input().split()))

list_odd=v[1::2]
list_even=v[0::2]

cnt_odd=Counter(list_odd)
cnt_even=Counter(list_even)

cnt_odd_sorted=sorted(cnt_odd.items(),reverse=True,key=lambda x:x[1])
cnt_even_sorted=sorted(cnt_even.items(),reverse=True,key=lambda x:x[1])

if cnt_odd_sorted[0][0]!=cnt_even_sorted[0][0]:
    ans=len(list_odd)-cnt_odd_sorted[0][1]
    ans+=len(list_even)-cnt_even_sorted[0][1]

else:
    if len(cnt_odd)==1 and len(cnt_even)==1:
        ans=len(list_even)
    elif len(cnt_odd)==1:
        ans=len(list_even)-cnt_even_sorted[1][1]
    elif len(cnt_even)==1:
        ans=len(list_odd)-cnt_odd_sorted[1][1]
    else:
        ans1=len(list_even)-cnt_even_sorted[1][1]
        ans1+=len(list_odd)-cnt_odd_sorted[0][1]

        ans2=len(list_odd)-cnt_odd_sorted[1][1]
        ans2+=len(list_even)-cnt_even_sorted[0][1]
        ans=min(ans1,ans2)

print(ans)

n = int(input())
v = list(map(int, input().split()))

first = {}
second = {}

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

first = sorted(first.items(), key=lambda x: x[1])
second = sorted(second.items(), key=lambda x: x[1])

f = first.pop()
s = second.pop()

if f[0] == s[0]:
    if len(first) >= 1:
        if len(second) >= 1:
            f2 = first.pop()
            s2 = second.pop()

            if f2[1] + s[1] > f[1] + s2[1]:
                f = f2
            else:
                s = s2
        else:
            s = second.pop()
    elif len(second) >= 1:
        f = first.pop()
    else:
        s = (0, 0)

print(n-f[1]-s[1])

from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
D1 = defaultdict(int)
D2 = defaultdict(int)

for i in range(0,N,2):
  D1[A[i]]+=1
for i in range(1,N,2):
  D2[A[i]]+=1
  
D1_sorted = sorted(D1.items(), key=lambda x:x[1], reverse = True) + [(-1,0)]
D2_sorted = sorted(D2.items(), key=lambda x:x[1], reverse = True) + [(-1,0)]
i, j = 0, 0
while i < len(D1_sorted) -1 and j < len(D2_sorted) -1:
  if D1_sorted[i][0] != D2_sorted[j][0]:
    break
  elif D1_sorted[i][1] > D2_sorted[j][1]:
    j+=1
  elif D1_sorted[i][1] < D2_sorted[j][1]:
    i+=1
  else:
    if D1_sorted[i+1][1] > D2_sorted[j+1][1]:
      i+=1
    else:
      j+=1

print(N-D1_sorted[i][1]-D2_sorted[j][1])

N=int(input())
*V,=map(int,input().split())
import collections

import collections

c1=collections.Counter(V[0::2])
c1=sorted(c1.items(), key=lambda x: x[1], reverse=True)
e=c1[0][0]

c2=collections.Counter(V[1::2])
c2=sorted(c2.items(), key=lambda x: x[1], reverse=True)
o=c2[0][0]

cnt=0
if e!=o:
    cnt=sum(e!=i for i in V[0::2])
    cnt+=sum(o!=i for i in V[1::2])
else:
    if len(c1)==1 and len(c2)==1:
        cnt=N//2
    elif len(c1)==1:
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(e!=i for i in V[0::2])
        cnt2+=sum(c2[1][1]!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    elif len(c2)==1:
        cnt1=sum(c1[1][0]!=i for i in V[0::2])
        cnt1+=sum(o!=i for i in V[1::2])

        cnt2=sum(c1[1][1]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    else:    
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(c1[1][0]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
print(cnt)

from collections import Counter

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    print((n // 2))
    return

kisu = Counter(v[::2]).most_common(2)
gusu = Counter(v[1::2]).most_common(2)

if kisu[0][0] == gusu[0][0]:
    keep = max(kisu[1][1] + gusu[0][1],
               kisu[0][1] + gusu[1][1])
else:
    keep = kisu[0][1] + gusu[0][1]

print((n - keep))


n = int(input())
l = list(map(int, input().split()))
a = {}
b = {}
for i in range(n // 2):
    key_a = l[i * 2]
    key_b = l[i * 2 + 1]
    if key_a in a:
        a[key_a] = a[key_a] + 1
    else:
        a[l[i * 2]] = 1
    if key_b in b:
        b[key_b] = b[key_b] + 1
    else:
        b[key_b] = 1
a = sorted(a.items(), key=lambda x: x[1], reverse=True)
b = sorted(b.items(), key=lambda x: x[1], reverse=True)
ca_max = a[0][0]
cb_max = b[0][0]
ca_max_num = a[0][1]
cb_max_num = b[0][1]
same_num = ca_max_num + cb_max_num
if ca_max == cb_max:
    if len(a) > 1:
        next_ca_max = a[1][1]
    else:
        next_ca_max = 0
    if len(b) > 1:
        next_cb_max = b[1][1]
    else:
        next_cb_max = 0
    same_num = max(ca_max_num + next_cb_max, cb_max_num + next_ca_max)
print(n - same_num)

import collections

n = int(input())
vs = list(map(int, input().split()))

vs_even = vs[0::2]
vs_odd = vs[1::2]

count_e = collections.Counter(vs_even).most_common()
count_o = collections.Counter(vs_odd).most_common()

#ダミー
count_e.append((0,0))
count_o.append((0,0))


e_max = len(vs_even) - count_e[0][1]
e_second = len(vs_even) - count_e[1][1]
o_max = len(vs_odd) - count_o[0][1]
o_second = len(vs_odd) - count_o[1][1]

if(count_e[0][0] != count_o[0][0]):
    print(e_max + o_max)

else:
    print(min(e_second+o_max, e_max+o_second))

import sys
from collections import Counter

input = sys.stdin.readline
N = int(input())
V = list(map(int, input().split()))

v1 = []
v2 = []
 
for i, v in enumerate(V):
    if i % 2 == 0:
        v1.append(v)
    else:
        v2.append(v)
 
v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()
 
k1, v1 = v1c[0][0], v1c[0][1]
k2, v2 = v2c[0][0], v2c[0][1]

ans = N 
if k1 == k2:
    ans -= v1
    m = 0
    if len(v1c) >= 2:
        m = max(m, v1c[1][1])
    if len(v2c) >= 2:
        m = max(m, v2c[1][1])
    ans -= m
else:
    ans -= v1 + v2
 
print(ans)

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 21:11:38 2020

@author: liang
"""

"""
【２番目の取得】
"""
n = int(input())
E = list()
O = list()
i = 0
for v in input().split():
    if i%2 == 0:
        E.append(int(v))
    else:
        O.append(int(v))
    i += 1
#print(E)
#print(O)
edic = {}
odic = {}
for e in E:
    if e not in edic.keys():
        edic[e] = 1
    else:
        edic[e] += 1

for o in O:
    if o not in odic.keys():
        odic[o] = 1
    else:
        odic[o] += 1
        
etmp = [(-1,0),(-1,0)]
otmp = [(-1,0),(-1,0)]

for key in edic.keys():
    #first
    if edic[key] > etmp[0][1]:
        etmp[1] = etmp[0]
        etmp[0] = (key, edic[key])
    #second
    elif edic[key] > etmp[1][1]:
        etmp[1] = (key,edic[key])

for key in odic.keys():
    #first
    if odic[key] > otmp[0][1]:
        otmp[1] = otmp[0]
        otmp[0] = (key, odic[key])
    #second
    elif odic[key] > otmp[1][1]:
        otmp[1] = (key,odic[key])

if etmp[0][0] == otmp[0][0]:
    ans = max(etmp[0][1]+otmp[1][1],etmp[1][1]+otmp[0][1])
else:
    ans = etmp[0][1]+otmp[0][1]
print(n-ans)

n = int(input())
v = list(map(int, input().split()))

v_even = [0]*100000
v_odd = [0]*100000

for i in range(n):
  if i%2==0:
    v_even[v[i]-1] += 1 
  else:
    v_odd[v[i]-1] += 1
    
res1 = max(v_even)
res2 = max(v_odd)
if v_even.index(res1) == v_odd.index(res2):
  if res1 > res2:
    v_odd[v_odd.index(res2)] = 0
    res2 = max(v_odd)
  elif res2 > res1:
    v_even[v_even.index(res1)] = 0
    res1 = max(v_even)
  elif res1 == res2:
    v_odd[v_odd.index(res2)] = 0
    v_even[v_even.index(res1)] = 0
    res3 = max(v_even)
    res4 = max(v_odd)
    if res3 > res4:
      res1 = res3
    else:
      res2 = res4
      
print(n//2-res1 + n//2-res2)

import collections

n = int(input())
v = [int(i) for i in input().split()]
con_odd = []
con_even = []
for i in range(0,n,2):
    con_odd.append(v[i]) 
    con_even.append(v[i+1])

b = collections.Counter(con_odd)
c = sorted(b.items(), key=lambda x:x[1],reverse = True)
b_2 = collections.Counter(con_even)
c_2 = sorted(b_2.items(), key=lambda x:x[1],reverse = True)
if len(c) == 1 and len(c_2) == 1:
    if c[0][0] == c_2[0][0]:
        ans = n//2
    else:
        ans = 0
elif len(c) == 1 or len(c_2) == 1:
    if c[0][0] == c_2[0][0]:
        if len(c) == 1:
            ans_1 = len(con_odd) - c[0][1]
            ans_2 = len(con_even) - c_2[1][1]
            ans = ans_1 + ans_2
        else:
            ans_1 = len(con_odd) - c[1][1]
            ans_2 = len(con_even) - c_2[0][1]
            ans = ans_1 + ans_2
    else:
        ans_1 = len(con_odd) - c[0][1]
        ans_2 = len(con_even) - c_2[0][1]
        ans = ans_1 + ans_2
            
elif c[0][0] == c_2[0][0]:
    if c[0][1] + c_2[1][1] > c[1][1] + c_2[0][1]:
        ans_1 = len(con_odd) - c[0][1]
        ans_2 = len(con_even) - c_2[1][1]
        ans = ans_1 + ans_2
    else:
        ans_1 = len(con_odd) - c[1][1]
        ans_2 = len(con_even) - c_2[0][1]
        ans = ans_1 + ans_2
else:
    ans_1 = len(con_odd) - c[0][1]
    ans_2 = len(con_even) - c_2[0][1]
    ans = ans_1 + ans_2
print(ans)

import copy

n = int(input())
v = list(map(int, input().split()))
# print(v)

la = [0 for i in range(5+10**5)]
lb = [0 for i in range(5+10**5)]

for i in range(0, n, 2):
    la[v[i]] += 1
for i in range(1, n, 2):
    lb[v[i]] += 1

# print(sum(la))
# print(sum(lb))
# print(max(la))
# print(max(lb))
# print(la.index(max(la)))
# print(lb.index(max(lb)))

sla = sum(la)
slb = sum(lb)
maxla = max(la)
maxlb = max(lb)
argmaxla = la.index(max(la))
argmaxlb = lb.index(max(lb))

if argmaxla != argmaxlb:
    if sla-maxla == 0 and slb-maxlb == 0:
        print((0))
    else:
        print((sla-maxla+slb-maxlb))
else:
    # laの2番目に大きい値を使う
    _la = copy.deepcopy(la)
    _la[argmaxla] = 0
    _maxla = max(_la)
    aa = sla-_maxla+slb-maxlb
    # lbの2番目に大きい値を使う
    _lb = copy.deepcopy(lb)
    _lb[argmaxlb] = 0
    _maxlb = max(_lb)
    bb = sla-maxla+slb-_maxlb
    if bb > aa:
        print(aa)
    else:
        print(bb)


import sys
from collections import Counter


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return list(map(int, stdin.readline().split()))
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    V = nl()
    V_e = V[0::2]
    V_o = V[1::2]
    V_e_c = Counter(V_e)
    V_o_c = Counter(V_o)

    if V_e_c.most_common()[0][0] != V_o_c.most_common()[0][0]:
        ans = len(V) - \
            V_e_c.most_common()[0][1] - V_o_c.most_common()[0][1]

    else:
        if len(V_e_c.most_common()) == 1 or len(V_o_c.most_common()) == 1:
            if len(V_e_c.most_common()) == 1 and len(V_o_c.most_common()) == 1:
                ans = len(V) // 2
            else:
                if len(V_e_c.most_common()) != 1:
                    ans = len(V) // 2 - V_e_c.most_common()[1][1]
                else:
                    ans = len(V) // 2 - V_o_c.most_common()[1][1]

        else:
            ans = len(V) - max(
                V_e_c.most_common()[0][1] + V_o_c.most_common()[1][1],
                V_e_c.most_common()[1][1] + V_o_c.most_common()[0][1],
            )

    print(ans)


def __starting_point():
    main()

__starting_point()