CodeEff/ECCO huggingface dataset:
# Original solution
from collections import Counter
n = eval(input())
V = list(map(int, input().split(" ")))

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

f1 = Counter(v1).most_common(2)
f2 = Counter(v2).most_common(2)

ans = 0

if len(set(v1)) == len(set(v2)) == 1:
    if v1 == v2:
        ans = min(len(v1), len(v2))
else:
    if f1[0][0] != f2[0][0]:
        ans = (len(v1) - f1[0][1]) + (len(v2) - f2[0][1])
    else:
        ans1 = (len(v1) - f1[0][1]) + (len(v2) - f2[1][1])
        ans2 = (len(v1) - f1[1][1]) + (len(v2) - f2[0][1])
        ans = min(ans1, ans2)

print(ans)


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

"""
9
1 1 1 1 2 2 2 4 
1 1 1 1 3 3 4 4
"""

#V = [1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 3, 2, 4, 4, 4]

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

f1 = Counter(v1).most_common(2)
f2 = Counter(v2).most_common(2)

ans = 0

if len(set(v1)) == len(set(v2)) == 1:
    if v1 == v2:
        ans = min(len(v1), len(v2))
else:
    if f1[0][0] != f2[0][0]:
        ans = (len(v1) - f1[0][1]) + (len(v2) - f2[0][1])
    else:
        if f1[1][1] < f2[1][1]:
            ans = (len(v1) - f1[0][1]) + (len(v2) - f2[1][1])
        else:
            ans = (len(v1) - f1[1][1]) + (len(v2) - f2[0][1])
        
print(ans)
# Original solution
from collections import Counter

n = int(eval(input()))
v = [int(x) for x in input().split()]

odd = sorted(list(Counter(v[0:n:2]).items()), reverse=True, key=lambda x: x[1])
even = sorted(list(Counter(v[1:n+1:2]).items()), reverse=True, key=lambda x: x[1])

if odd[0][0] != even[0][0]:
    res = n - odd[0][1] - even[0][1]
elif len(odd) == 1:
    res = odd[0][1]
else:
    if odd[0][1] == even[0][1]:
        if odd[1][1] >= even[1][1]:
            res = n - odd[1][1] - even[0][1]
        else:
            res = n - odd[0][1] - even[1][1]
    elif odd[0][1] > even[0][1]:
        res = n - odd[0][1] - even[1][1]
    else:
        res = n - odd[1][1] - even[0][1]

print(res)


# Optimized solution
from collections import Counter

n = int(eval(input()))
v = [int(x) for x in input().split()]

v1 = Counter(v[0::2]).most_common() + [(0, 0)]
v2 = Counter(v[1::2]).most_common() + [(0, 0)]

if v1[0] != v2[0]:
    res = n - v1[0][1] - v2[0][1]
else:
    res = min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1])

print(res)
# Original solution
from collections import Counter
n = int(eval(input()))
v_tmp = input().split()
v = [int(_) for _ in v_tmp]
v_count = Counter(v_tmp)
# print(v_count)
if len(v_count) == 1:
    print((n//2))
else:
    # print("hoge")
    v_keys = list(v_count.keys())
    tmps = []
    # print(v_keys)
    for _ in v_keys:
        for _2 in v_keys:
            tmp = []
            # print(_, _2)
            if _ == _2:
                continue
            else:
                for i in range(n):
                    if i % 2 == 0:
                        tmp.append(_)
                    else:
                        tmp.append(_2)
            # print("tmp", tmp)
            if tmp == []:
                continue
            else:
                tmps.append(tmp)
    sols = []
    for _ in tmps:
        sol_tmp = 0
        for i in range(n):
            if _[i] != v_tmp[i]:
                sol_tmp += 1
        sols.append(sol_tmp)
    print((min(sols)))


# Optimized solution
from collections import Counter
n = int(eval(input()))
v = [int(_) for _ in input().split()]
v1 = []
v2 = []
for i in range(n):
    if i % 2 == 0:
        v1.append(v[i])
    else:
        v2.append(v[i])
v_count = Counter(v)
v1_count = Counter(v1)
v2_count = Counter(v2)
# print("v1_count", v1_count)
# print("v2_count", v2_count)
v1_comm = v1_count.most_common(1)
v2_comm = v2_count.most_common(1)
sols = []
# print("v1_comm", v1_comm)
# print("v2_comm", v2_comm)
if len(v_count) == 1:
    print((n//2))
else:
    key1 = v1_comm[0][1]
    # print("v1_comm[0][0]", v1_comm[0][0])
    # print("v2_comm[0][0]", v2_comm[0][0])
    if v1_comm[0][0] == v2_comm[0][0]:
        # print("hoge")
        v2_comm = v2_count.most_common(2)
        key2 = v2_comm[1][1]
    else:
        key2 = v2_comm[0][1]
    sols.append(n-key1-key2)
    key1 = v2_comm[0][1]
    if v1_comm[0][0] == v2_comm[0][0]:
        v1_comm = v1_count.most_common(2)
        key2 = v1_comm[1][1]
    else:
        key2 = v1_comm[0][1]
    sols.append(n-key1-key2)
    print((min(sols)))
# Original solution
from collections import Counter

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

f = Counter(v[::2])
s = Counter(v[1::2])

ans = []

for i in list(f.keys()):
    for j in list(s.keys()):
        if i == j:
            continue
        else:
            ans.append(f[i] + s[j])

if ans:
    print((n - max(ans)))
else:
    print((n // 2))

# Optimized solution
from collections import Counter

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

f = Counter(v[::2]).most_common(2)
s = Counter(v[1::2]).most_common(2)

if f[0][0] != s[0][0]:
    print((n - f[0][1] - s[0][1]))
else:
    if len(f) == 1 or len(s) == 1:
        print((n // 2))
    else:
        print((n - max(f[0][1] + s[1][1], f[1][1] + s[0][1])))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
b = a[0::2]
b1 = sorted(b, key=lambda x: b.count(x))
c = a[1::2]
c1 = sorted(c, key=lambda x: c.count(x))

if b == c:
    print((n//2))
else:
    print((n - b1.count(b1[-1]) - c1.count(c1[-1])))

# Optimized solution
n = int(eval(input()))
v = list(map(int,input().split()))
v1 = sorted(v[0::2])
v2 = sorted(v[1::2])
s1 = set(v1)
s2 = set(v2)

## 偶数項・奇数項ごとに最大数および次点の値を保持
eve = [[0,0]]
odd = [[0,0]]
cnt_eve = 1
cnt_odd = 1

for i in range(1,n//2):
    ## 偶数
    if v1[i] == v1[i-1]:
        cnt_eve += 1
    else:
        eve.append([cnt_eve, v1[i-1]])
        cnt_eve = 1
    if v2[i] == v2[i-1]:
        cnt_odd += 1
    else:
        odd.append([cnt_odd, v2[i-1]])
        cnt_odd = 1
    if i == n//2 - 1:
        eve.append([cnt_eve, v1[i]])
        odd.append([cnt_odd, v2[i]])


eve.sort(key=lambda x: x[0], reverse=True)
odd.sort(key=lambda x: x[0], reverse=True)

if eve[0][1] != odd[0][1]:
    ans = n - eve[0][0] - odd[0][0]
    print(ans)
else:
    ans = n - max(eve[0][0] + odd[1][0], eve[1][0] + odd[0][0])
    print(ans)
# Original solution
from collections import Counter

n = int(eval(input()))

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

odds = []
evens = []

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

evens_c = Counter(evens).most_common()
odds_c = Counter(odds).most_common()

ans = n

fl = 0
for i in range(len(evens_c)):
    for j in range(len(odds_c)):
        try:
            if evens_c[i][0] != odds_c[j][0]:
                ans = min(ans, n - evens_c[i][1] - odds_c[j][1])
                fl = 1
        except:
            continue

if fl == 1:
    print(ans)
    exit()
print((n // 2))


# Optimized solution
from collections import Counter

n = int(eval(input()))

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

odds = []
evens = []

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

evens_c = Counter(evens).most_common(2)
odds_c = Counter(odds).most_common(2)

if evens_c[0][0] != odds_c[0][0]:
    print((n - evens_c[0][1] - odds_c[0][1]))
    exit()

if len(evens_c) == 1 or len(odds_c) == 1:
    print((n // 2))
    exit()

print((n - max(evens_c[0][1] + odds_c[1][1], evens_c[1][1] + odds_c[0][1])))
# Original solution
n = int(eval(input()))
lst = list(map(int, input().split()))
ma = {}
mb = {}
for i in range(0, n, 2):
    lst[i] in ma
    if lst[i] in ma:
        ma[lst[i]] += 1
    else:
        ma[lst[i]] = 1
    lst[i+1] in mb
    if lst[i+1] in mb:
        mb[lst[i+1]] += 1
    else:
        mb[lst[i+1]] = 1
if max(ma, key=ma.get) != max(mb, key=mb.get):
    d = n - max(ma.values()) - max(mb.values())
else:
    ma2 = max(ma.values())
    mb2 = max(mb.values())
    ma[max(ma, key=ma.get)] = 0
    mb[max(mb, key=mb.get)] = 0
    d1 = n - ma2 - max(mb.values())
    d2 = n - max(ma.values()) - mb2
    d = min(d1, d2)
print(d)

# Optimized solution
n = int(eval(input()))
lst = list(map(int, input().split()))
m1 = {}
m2 = {}
for i in range(0, n, 2):
    if lst[i] in m1:
        m1[lst[i]] += 1
    else:
        m1[lst[i]] = 1
    if lst[i+1] in m2:
        m2[lst[i+1]] += 1
    else:
        m2[lst[i+1]] = 1
if max(m1, key=m1.get) != max(m2, key=m2.get):
    mm = n - max(m1.values()) - max(m2.values())
else:
    mm1 = max(m1.values())
    mm2 = max(m2.values())
    m1[max(m1, key=m1.get)] = 0
    m2[max(m2, key=m2.get)] = 0
    mm = min(n - max(m1.values()) - mm2, n - max(m2.values()) - mm1) 
print(mm)
# Original solution
from itertools import permutations
import collections
N = int(eval(input()))
nums = list(map(int, input().split()))
odd_nums = []
even_nums = []
for i, num in enumerate(nums):
    if i % 2 == 1:
        even_nums.append(num)
    else:
        odd_nums.append(num)

useable_nums = set(nums)
even_length = len(even_nums)
odd_length = len(odd_nums)
even_counter = collections.Counter(even_nums)
odd_counter = collections.Counter(odd_nums)
# print(even_counter)  # 偶数
# print(odd_counter)  # 奇数
inf = float('inf')
min_ans = inf
if len(useable_nums) == 1:
    useable_nums.add(0)
useable_permutaions = list(permutations(useable_nums, 2))
# print(useable_permutaions)

for permutation in useable_permutaions:
    ans = 0
    if permutation[0] in odd_counter:
        ans += odd_length - odd_counter[permutation[0]]
    else:
        ans += odd_length
    if permutation[1] in even_counter:
        ans += even_length - even_counter[permutation[1]]
    else:
        ans += even_length
    min_ans = min(min_ans, ans)

print(min_ans)


# Optimized solution
from itertools import permutations
import collections
N = int(eval(input()))
nums = list(map(int, input().split()))
odd_nums = []
even_nums = []
for i, num in enumerate(nums):
    if i % 2 == 1:
        even_nums.append(num)
    else:
        odd_nums.append(num)

useable_nums = set(nums)
even_length = len(even_nums)
odd_length = len(odd_nums)
even_counter = collections.Counter(even_nums).most_common()
odd_counter = collections.Counter(odd_nums).most_common()
even_counter.append((0, 0))
odd_counter.append((0, 0))
even_counter.sort(key=lambda x: x[1], reverse=True)
odd_counter.sort(key=lambda x: x[1], reverse=True)
# print(even_counter)
# print(odd_counter)


min_ans = None
if even_counter[0][0] == odd_counter[0][0]:
    min_ans = min((odd_length - odd_counter[0][1]) + (even_length - even_counter[1][1]),
                  (odd_length - odd_counter[1][1]) + (even_length - even_counter[0][1]))
else:

    min_ans = odd_length - odd_counter[0][1] + even_length - even_counter[0][1]
print(min_ans)
# Original solution
from collections import defaultdict

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

if len(set(L)) == 1:
    print((N//2))
    exit()
if N == 2:
    print((0))
    exit()


d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = L[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

l_even = sorted(list(d_even.items()), key=lambda x: -x[1])
l_odd = sorted(list(d_odd.items()), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print((N - l_even[0][1] - l_odd[0][1]))
else:
    # どちらも試してコストの小さい方を採用する
    ans1 = N - l_even[0][1] - l_odd[1][1]
    ans2 = N - l_even[1][1] - l_odd[0][1]
    print((min(ans1, ans2)))


# Optimized solution
from collections import defaultdict

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

if len(set(L)) == 1:
    print((N//2))
    exit()
if N == 2:
    print((0))
    exit()


d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = L[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

l_even = sorted(list(d_even.items()), key=lambda x: -x[1])
l_odd = sorted(list(d_odd.items()), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print((N - l_odd[0][1] - l_even[0][1]))
    exit()

ans = N
ans = min(ans, N - l_odd[0][1] - l_even[1][1])
ans = min(ans, N - l_odd[1][1] - l_even[0][1])
print(ans)
# Original solution
from collections import defaultdict

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

if len(set(L)) == 1:
    print((N//2))
    exit()
if N == 2:
    print((0))
    exit()


d_even = defaultdict(int)
d_odd = defaultdict(int)

for i in range(N):
    v = L[i]
    if i % 2 == 0:
        d_even[v] += 1
    else:
        d_odd[v] += 1

l_even = sorted(list(d_even.items()), key=lambda x: -x[1])
l_odd = sorted(list(d_odd.items()), key=lambda x: -x[1])

if l_even[0][0] != l_odd[0][0]:
    print((N - l_odd[0][1] - l_even[0][1]))
    exit()

ans = N
ans = min(ans, N - l_odd[0][1] - l_even[1][1])
ans = min(ans, N - l_odd[1][1] - l_even[0][1])
print(ans)


# Optimized solution
from collections import Counter

N = int(eval(input()))
L = list(map(int, input().split()))
odd = [v for i, v in enumerate(L) if i % 2 == 0]
even = [v for i, v in enumerate(L) if i % 2 == 1]

if len(set(L)) == 1:
    print((N//2))
    exit()
if N == 2:
    print((0))
    exit()


c_odd = sorted(list(dict(Counter(odd)).items()), key=lambda x: -x[1])
c_even = sorted(list(dict(Counter(even)).items()), key=lambda x: -x[1])

odd_1 = c_odd[0]
even_1 = c_even[0]

if odd_1[0] != even_1[0]:
    print((N - odd_1[1] - even_1[1]))
    exit()

even_2 = c_even[1]
odd_2 = c_odd[1]

ans = N
ans = min(ans, N - odd_1[1] - even_2[1])
ans = min(ans, N - odd_2[1] - even_1[1])
print(ans)
# Original solution
from collections import Counter
n = int(eval(input()))
num = list(map(int, input().split()))
num1 = []
num2 = []
ans = 0

for i in range(0, n, 2):
    num1.append(num[i])
    
for i in range(1, n, 2):
    num2.append(num[i])

num1 = Counter(num1).most_common()
num2 = Counter(num2).most_common()    

if num1[0][0] != num2[0][0]:
    ans = n - num1[0][1] - num2[0][1]
else:
    if n - num1[0][1] - num2[0][1] == 0:
        ans = n // 2
    else:
        if n // 2 - num1[0][1] == 0:
            ans = n // 2 - num2[1][1]
        elif n // 2 - num2[0][1] == 0:
            ans = n // 2 - num1[1][1]
        else:
            a = n - num1[0][1] - num2[1][1]
            b = n - num1[1][1] - num2[0][1]
            ans = min(a, b)

print(ans)

# Optimized solution
from collections import Counter

n = int(eval(input()))
V = list(map(int, input().split()))
X = Counter([V[i] for i in range(0, n, 2)]).most_common()
Y = Counter([V[i] for i in range(1, n, 2)]).most_common()

ans = 0

if X[0][0] != Y[0][0]:
    ans = n - X[0][1] - Y[0][1]
else:
    if len(X) == 1 and len(Y) == 1:
        ans = n // 2
    elif len(X) == 1 and len(Y) != 1:
        ans = n // 2 - Y[1][1]
    elif len(X) != 1 and len(Y) == 1:
        ans = n // 2 - X[1][1]
    else:
        a = n - X[0][1] - Y[1][1]
        b = n - X[1][1] - Y[0][1]
        ans = min(a, b)
        
print(ans)
# Original solution
from collections import Counter

n = int(eval(input()))
A = [int(i) for i in input().split()]
A0 = []
A1 = []
for i in range(0, n, 2):
    A0.append(A[i])
    A1.append(A[i + 1])
    
C0 = Counter(A0).most_common()
C1 = Counter(A1).most_common()

if C0[0][0] != C1[0][0]:
    ans = n - C0[0][1] - C1[0][1]
else:
    if len(C0) == 1 and len(C1) == 1:
        ans = n // 2
    elif len(C0) != 1 and len(C1) != 1:
        ans = min(n - C0[0][1] - C1[1][1], n - C0[1][1] - C1[0][1])
    elif len(C0) != 1 and len(C1) == 1:
        ans = n // 2 - C0[0][1]
    else:
        ans = n // 2 - C1[0][1]
        
print(ans)

# Optimized solution
from collections import Counter

n = int(eval(input()))
A = [int(i) for i in input().split()]
S = Counter(A[0::2]).most_common()
T = Counter(A[1::2]).most_common()

if S[0][0] != T[0][0]:
    ans = n - S[0][1] - T[0][1]
elif S[0][0] == T[0][0]:
    if len(S) == 1 and len(T) > 1:
        ans = n // 2 - T[0][1]
    elif len(S) > 1 and len(T) == 1:
        ans = n // 2 - S[0][1]
    elif len(S) > 1 and len(T) > 1:
        ans = min(n - S[0][1] - T[1][1], n - S[1][1] - T[0][1])
    else:
        ans = n // 2
        
print(ans)
# Original solution
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))

li1 = []
li2 = []

for i in range(n):
    if i % 2 == 0:
        li1.append(li[i])
    else:
        li2.append(li[i])

li1.sort()
li2.sort()

lin = []
lin2 = []

for key, value in groupby(li1):
    lin.append((key,len(list(value))))
for key, value in groupby(li2):
    lin2.append((key,len(list(value))))

lin.sort(key=lambda x:(x[1]))
lin2.sort(key=lambda x:(x[1]))

point = 0

if lin[-1][0] == lin2[-1][0] and lin[-1][1] == lin2[-1][1]:
    if len(lin) == 1:
        print((n//2))
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print((n-lin[-2][1]-lin2[-1][1]))
        else:
            print((n-lin[-1][1]-lin2[-2][1]))

elif lin[-1][0] == lin2[-1][0]:
    if len(lin) == 1:
        print((n//2-lin2[-2][1]))
    elif len(lin2) == 1:
        print((n//2-lin[-2][1]))
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print((n-lin[-1][1]-lin2[-2][1]))
        else:
            print((n-lin[-2][1]-lin2[-1][1]))
else:
    print((n-lin[-1][1]-lin2[-1][1]))

# Optimized solution
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))

li1 = []
li2 = []

for i in range(n):
    if i % 2 == 0:
        li1.append(li[i])
    else:
        li2.append(li[i])

li1.sort()
li2.sort()

lin = []
lin2 = []

for key, value in groupby(li1):
    lin.append((key,len(list(value))))
for key, value in groupby(li2):
    lin2.append((key,len(list(value))))

lin.sort(key=lambda x:(x[1]))
lin2.sort(key=lambda x:(x[1]))

point = 0

if lin[-1][0] == lin2[-1][0] and lin[-1][1] == lin2[-1][1]:
    if len(lin) == 1:
        print((n//2))
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print((n-lin[-2][1]-lin2[-1][1]))
        else:
            print((n-lin[-1][1]-lin2[-2][1]))

elif lin[-1][0] == lin2[-1][0]:
    if len(lin) == 1:
        print((n//2-lin2[-2][1]))
    elif len(lin2) == 1:
        print((n//2-lin[-2][1]))
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print((n-lin[-2][1]-lin2[-1][1]))
        else:
            print((n-lin[-1][1]-lin2[-2][1]))
else:
    print((n-lin[-1][1]-lin2[-1][1]))
# Original solution
#!/usr/bin/env python3
import collections
N = int(eval(input()))
V = list(map(int, input().split()))

V1 = V[::2]
V2 = V[1::2]

if len(set(V1)) == 1 and len(set(V2)) == 1 and V1[0] == V2[0]:
    print((len(V1)))
    exit()


C1 = collections.Counter(V1)
C2 = collections.Counter(V2)

C1_s = sorted(list(C1.items()), key=lambda x:x[1])[::-1]
C2_s = sorted(list(C2.items()), key=lambda x:x[1])[::-1]

max1 = C1_s[0][1]
index1 = C1_s[0][0]

max2 = C2_s[0][1]
index2 = C2_s[0][0]

max1_2 = 0
max2_2 = 0
if len(C1_s) > 1:
    max1_2 = C1_s[1][1]

if len(C2_s) > 1:
    max2_2 = C2_s[1][1]


nokori1 = len(V1) - max1
nokori2 = len(V2) - max2

nokori1_2 = len(V1) - max1_2
nokori2_2 = len(V2) - max2_2

ans = 0
if index1 == index2:
    if len(set(V1)) == 1:
        ans = nokori2_2
    elif len(set(V2)) == 1:
        ans = nokori1_2
    else:
        ans = min(nokori1_2 + nokori2, nokori1 + nokori2_2)
else:
    ans = nokori1 + nokori2
print(ans)


# Optimized solution
#!/usr/bin/env python3
import collections
N = int(eval(input()))
V = list(map(int, input().split()))

V1 = V[::2]
V2 = V[1::2]


C1 = collections.Counter(V1)
C2 = collections.Counter(V2)

C1_s = sorted(list(C1.items()), key=lambda x:x[1])[::-1]
C2_s = sorted(list(C2.items()), key=lambda x:x[1])[::-1]

max1 = C1_s[0][1]
index1 = C1_s[0][0]

max2 = C2_s[0][1]
index2 = C2_s[0][0]

max1_2 = 0
max2_2 = 0
if len(C1_s) > 1:
    max1_2 = C1_s[1][1]

if len(C2_s) > 1:
    max2_2 = C2_s[1][1]


nokori1 = len(V1) - max1
nokori2 = len(V2) - max2

nokori1_2 = len(V1) - max1_2
nokori2_2 = len(V2) - max2_2

ans = 0
if index1 == index2:
    ans = min(nokori1_2 + nokori2, nokori1 + nokori2_2)
else:
    ans = nokori1 + nokori2
print(ans)
# Original solution
#!/usr/bin/env python3
import collections
N = int(eval(input()))
V = list(map(int, input().split()))

V1 = V[::2]
V2 = V[1::2]


C1 = collections.Counter(V1)
C2 = collections.Counter(V2)

C1_s = sorted(list(C1.items()), key=lambda x:x[1])[::-1]
C2_s = sorted(list(C2.items()), key=lambda x:x[1])[::-1]

max1 = C1_s[0][1]
index1 = C1_s[0][0]

max2 = C2_s[0][1]
index2 = C2_s[0][0]

max1_2 = 0
max2_2 = 0
if len(C1_s) > 1:
    max1_2 = C1_s[1][1]

if len(C2_s) > 1:
    max2_2 = C2_s[1][1]


nokori1 = len(V1) - max1
nokori2 = len(V2) - max2

nokori1_2 = len(V1) - max1_2
nokori2_2 = len(V2) - max2_2

ans = 0
if index1 == index2:
    ans = min(nokori1_2 + nokori2, nokori1 + nokori2_2)
else:
    ans = nokori1 + nokori2
print(ans)


# Optimized solution
#!/usr/bin/env python3
import collections
N = int(eval(input()))
V = list(map(int, input().split()))

V1 = V[::2]
V2 = V[1::2]


C1 = collections.Counter(V1)
C2 = collections.Counter(V2)

C1_s = C1.most_common()
C2_s = C2.most_common()

max1 = C1_s[0][1]
index1 = C1_s[0][0]

max2 = C2_s[0][1]
index2 = C2_s[0][0]

max1_2 = 0
max2_2 = 0
if len(C1_s) > 1:
    max1_2 = C1_s[1][1]

if len(C2_s) > 1:
    max2_2 = C2_s[1][1]


nokori1 = len(V1) - max1
nokori2 = len(V2) - max2

nokori1_2 = len(V1) - max1_2
nokori2_2 = len(V2) - max2_2

ans = 0
if index1 == index2:
    ans = min(nokori1_2 + nokori2, nokori1 + nokori2_2)
else:
    ans = nokori1 + nokori2
print(ans)
# Original solution
a, b, c = list(map(int, input().split()))
if min(a, b) < c and c < max(a, b):
  print('Yes')
else:
  print('No')

# Optimized solution
a, b, c = list(map(int, input().split()))
if a <= c <= b or b <= c <= a:
    print('Yes')
else:
    print('No')
# Original solution
A, B, C = list(map(int,input().split()))
print(('Yes' if A<C<B or A>C>B else 'No'))

# Optimized solution
A, B, C = list(map(int, input().split()))
print(('Yes' if A-C>0 and C-B>0 or A-C<0 and C-B<0 else 'No'))
# Original solution
a, b, c = list(map(int, input().split()))
if a < c < b or b < c <a:
    print("Yes") 
else:
    print("No")

# Optimized solution
A, B, C = list(map(int, input().split()))
if A < C < B or B < C < A:
    print("Yes")
else:
    print("No")
# Original solution
A, B, C = list(map(int, input().split()))
if A < C and C < B:
    ans = "Yes"
elif B < C and C < A:
    ans = "Yes"
else:
    ans = "No"
print(ans)


# Optimized solution
def LI():
    return list(map(int, input().split()))


A, B, C = LI()
if A < C < B or B < C < A:
    ans = "Yes"
else:
    ans = "No"
print(ans)
# Original solution
while True:
  n = int(eval(input()))
  if n == 0:
    break
  tlst = []
  qlst = []
  for _ in range(n):
    m, a, b = list(map(int, input().split()))
    qlst.append((m, a, b))
    tlst.append(a)
    tlst.append(b)
    tlst.append(b - 1)
  tlst = sorted(list(set(tlst)))
  tlst.sort()
  tdic = {}
  for i, t in enumerate(tlst):
    tdic[t] = i
  lent = len(tlst)
  mp = [0] * lent
  for m, a, b in qlst:
    a, b = tdic[a], tdic[b]
    mp[a] += m
    mp[b] -= m
  
  acc = 0
  for i in range(lent):
    acc += mp[i]
    if acc > 150:
      print("NG")
      break
  else:
    print("OK")



# Optimized solution
while True:
  n = int(eval(input()))
  if n == 0:
    break
  tlst = []
  qlst = []
  for _ in range(n):
    m, a, b = list(map(int, input().split()))
    qlst.append((m, a, b))
    tlst.append(a)
    tlst.append(b)
  tlst = sorted(list(set(tlst)))
  tlst.sort()
  tdic = {}
  for i, t in enumerate(tlst):
    tdic[t] = i
  lent = len(tlst)
  mp = [0] * lent
  for m, a, b in qlst:
    a, b = tdic[a], tdic[b]
    mp[a] += m
    mp[b] -= m
  
  acc = 0
  for i in range(lent):
    acc += mp[i]
    if acc > 150:
      print("NG")
      break
  else:
    print("OK")