qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
input_line = str(input())
s = []

for i in range(len(input_line)):
  if input_line == '9':
    s.append('1')
  elif input_line == '1':
    s.append('9')
  else:
    s.append(input_line[i])

for x in s:
    mojiretu += x
    
print(mojiretu)


# Fixed code:
input_line = str(input())
s = []

for i in range(len(input_line)):
    if input_line[i] == '9':
        s.append('1')
    elif input_line[i] == '1':
        s.append('9')
    else:
        s.append(input_line[i])

mojiretu = ''

for x in s:
    mojiretu += x

print(int(mojiretu))
# Buggy code:
n = input()
ans = 0
for l in n:
  if l == '1':
    ans += 9
  else:
    ans += 1
print(ans)

# Fixed code:
n = input()
ans =''
for l in n:
  if l == '1':
    ans += '9'
  else:
    ans += '1'
print(ans)
# Buggy code:
n = input()
print(n.replace("1", "9").replace("9", "1"))

# Fixed code:
n = input()
print(n.replace('9','x').replace('1','9').replace('x','1'))
# Buggy code:
n=input()
for i in range(len(n)):
    if n[i]=="1":
        n[i]="9"
    else:
        n[i]="1"
print(n)


# Fixed code:
n=input()
ans=""
for i in range(len(n)):
    if n[i]=="1":
        ans+="9"
    else:
        ans+="1"
print(ans)
# Buggy code:
s = input()
changer = {"1":"9", "9":"1"}
answer = ""
for chr in s:
  answer = changer[chr] + answer
print(int(answer))

# Fixed code:
s = input()
changer = {"1":"9", "9":"1"}
answer = ""
for chr in s:
    answer += changer[chr] #+ answer
print(int(answer))
# Buggy code:
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()

if dic1[0][0]!=dic2[0][0]:
  print(n - dic1[0][1] - dic2[0][1]+1)
else:
  print(min(n - dic1[0][1] - dic2[1][1]+1, n -dic1[1][1] - dic2[0][1]+1))

# Fixed code:
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]))
# Buggy code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**7)
mod = 10**9+7
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def counter_top(c,exclude):
    for a in c.most_common():
        if a[0]!=exclude:
            return a
    return (object(),0)

def conv_seq(seq,exclude = None):
    c = collections.Counter(seq)
    mc = counter_top(c,exclude)
    return sum(c.values()) - mc[1],mc[0]

N = I()
V = LI()

l = [V[i] for  i in range(0,N,2)]
r = [V[i] for i in range(1,N,2)]

s1,a = conv_seq(V[::2])
s2,b = conv_seq(V[1::2])

if s1!=s2:
    print(a+b)
else:
    s1_new,_ = conv_seq(V[::2],exclude=b)
    s2_new,_ = conv_seq(V[1::2],exclude=a)
    print(min(s1_new+s2,s1+s2_new))

# Fixed code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**7)
mod = 10**9+7
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def counter_top(c,exclude):
    for a in c.most_common():
        if a[0]!=exclude:
            return a
    return (object(),0)

def conv_seq(seq,exclude = None):
    c = collections.Counter(seq)
    mc = counter_top(c,exclude)
    return sum(c.values()) - mc[1],mc[0]

N = I()
V = LI()

s1,a = conv_seq(V[::2])
s2,b = conv_seq(V[1::2])


if s1!=s2:
    print(s1+s2)
else:
    s1_new,_ = conv_seq(V[::2],exclude=b)
    s2_new,_ = conv_seq(V[1::2],exclude=a)
    print(min(s1_new+s2,s1+s2_new))
# Buggy code:
from collections import defaultdict

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)]

cnt1 = defaultdict(int)
cnt2 = defaultdict(int)
for x in v1:
  cnt1[x] += 1
for x in v2:
  cnt2[x] += 1
vc1 = []
vc2 = []
for k, v in cnt1.items():
  vc1.append((v, k))
for k, v in cnt2.items():
  vc2.append((v, k))
vc1.sort()
vc1.reverse()
vc2.sort()
vc2.reverse()

vc1.append((0, vc1[0][0] + 1))
vc2.append((0, vc2[0][0] + 1))

ans = n
for _, x1 in vc1[:2]:
  for _, x2 in vc2[:2]:
    s = 0
    for x in v1:
      if x != x1: s += 1
    for x in v2:
      if x != x2: s += 1
    ans = min(ans, s)
print(ans)

# Fixed code:
from collections import defaultdict

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)]

cnt1 = defaultdict(int)
cnt2 = defaultdict(int)
for x in v1:
  cnt1[x] += 1
for x in v2:
  cnt2[x] += 1
vc1 = []
vc2 = []
for k, v in cnt1.items():
  vc1.append((v, k))
for k, v in cnt2.items():
  vc2.append((v, k))
vc1.sort()
vc1.reverse()
vc2.sort()
vc2.reverse()

vc1.append((0, vc1[0][0] + 1))
vc2.append((0, vc2[0][0] + 1))

ans = n
for _, x1 in vc1[:2]:
  for _, x2 in vc2[:2]:
    if x1 == x2: continue
    s = 0
    for x in v1:
      if x != x1: s += 1
    for x in v2:
      if x != x2: s += 1
    ans = min(ans, s)
print(ans)
# Buggy code:
from collections import Counter

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

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else vp[0][1] == vn[0][1]:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vp[0][1]
            else:
                gp = vp[0][1]
                gn = vp[1][1]
 
    ans = n - gp - gn
print(ans)

# Fixed code:
from collections import Counter

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

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)
# Buggy code:
from collections import Counter

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

Vodd = V[: len(V):2]
Veven = V[1: len(V):2]

if Vodd == Veven:
    print(n // 2)


Voc = Counter(Vodd)
Vec = Counter(Veven)

Voc_val, Voc_cnt = zip(*Voc.most_common())
Vec_val, Vec_cnt = zip(*Vec.most_common())

Voc_val, Voc_cnt = list(Voc_val), list(Voc_cnt)
Vec_val, Vec_cnt = list(Vec_val), list(Vec_cnt)

num = Voc.most_common()[0][1] + Vec.most_common()[0][1]

if Voc_val[0] == Vec_val[0]:
    Voc_cnt.append(0)
    Vec_cnt.append(0)
    num += max(Voc_cnt[1] - Voc_cnt[0], Vec_cnt[1] - Vec_cnt[0])

print(n - num)


# Fixed code:
from collections import Counter

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

Vodd = V[: len(V):2]
Veven = V[1: len(V):2]

Voc = Counter(Vodd)
Vec = Counter(Veven)

Voc_val, Voc_cnt = zip(*Voc.most_common())
Vec_val, Vec_cnt = zip(*Vec.most_common())

Voc_val, Voc_cnt = list(Voc_val), list(Voc_cnt)
Vec_val, Vec_cnt = list(Vec_val), list(Vec_cnt)

num = Voc.most_common()[0][1] + Vec.most_common()[0][1]

if Voc_val[0] == Vec_val[0]:
    Voc_cnt.append(0)
    Vec_cnt.append(0)
    num += max(Voc_cnt[1] - Voc_cnt[0], Vec_cnt[1] - Vec_cnt[0])

print(n - num)
# Buggy code:
import itertools
import math
import fractions
import functools
import copy

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

kisu = [0]*(10**6)
gusu = [0]*(10**6)
for i in range(n):
    if i % 2 == 0:
        gusu[v[i]] += 1
    else:
        kisu[v[i]] += 1

count = 0 
gusu_m = gusu.index(max(gusu))
kisu_m = kisu.index(max(kisu))
for i in range(n):
    if i % 2 == 0 and gusu_m != v[i]:
        count += 1
    if i % 2 != 0 and kisu_m != v[i]:
        count += 1

print(count)



# Fixed code:
import itertools
import math
import fractions
import functools
import copy

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

kisu = [0]*(10**6)
gusu = [0]*(10**6)
for i in range(n):
    if i % 2 == 0:
        gusu[v[i]] += 1
    else:
        kisu[v[i]] += 1

count = 0
gusu_m = gusu.index(max(gusu))
kisu_m = kisu.index(max(kisu))

if gusu_m == kisu_m:

    gusu[gusu_m] = 0
    kisu[kisu_m] = 0
    if max(gusu) > max(kisu):
        gusu_m = gusu.index(max(gusu))
    else:
        kisu_m = kisu.index(max(kisu))

for i in range(n):
    if i % 2 == 0 and gusu_m != v[i]:
        count += 1
    if i % 2 != 0 and kisu_m != v[i]:
        count += 1

print(count)
# Buggy code:
import collections

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

list_e = [list[i] for i in range(0,n-1,2)]
list_o = [list[i] for i in range(1,n,2)]
e = collections.Counter(list_e)
o = collections.Counter(list_o)
mode_e=e.most_common(2)
mode_o=o.most_common(2)
if mode_e[0][0]==mode_o[0][0]:
    if mode_e[0][1]>mode_o[0][1]:
        mode_e_value=mode_e[0][1]
        mode_o_value=mode_o[1][1]
    else:
        mode_e_value=mode_e[1][1]
        mode_o_value=mode_o[0][1]
else:
    mode_e_value = mode_e[0][1]
    mode_o_value = mode_o[0][1]
print(n-mode_e_value-mode_o_value)


# Fixed code:
import collections

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

list_e = [list[i] for i in range(0,n-1,2)]
list_o = [list[i] for i in range(1,n,2)]
e = collections.Counter(list_e)
o = collections.Counter(list_o)
mode_e=e.most_common(2)
mode_o=o.most_common(2)
mode_e.append((-1,0))
mode_o.append((-1,0))
if mode_e[0][0]==mode_o[0][0]:
    print(n-max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1]))
    # if mode_e[0][1]>mode_o[0][1]:
    #     mode_e_value=mode_e[0][1]
    #     mode_o_value=mode_o[1][1]
    # else:
    #     mode_e_value=mode_e[1][1]
    #     mode_o_value=mode_o[0][1]
else:
    mode_e_value = mode_e[0][1]
    mode_o_value = mode_o[0][1]
    print(n-mode_e_value-mode_o_value)
# Buggy code:
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]))



# Fixed code:
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]))
# Buggy code:
import itertools
"""
n = int(input())
m, a, r, c, h = [0] * 5
for i in range(n):
    s = input()
    if s[0] == "M": m += 1
    if s[0] == "A": a += 1
    if s[0] == "R": r += 1
    if s[0] == "C": c += 1
    if s[0] == "H": h += 1
x = [m, a, r, c, h]
y = ["M", "A", "R", "C", "H"]
ans = 0
for i in itertools.combinations(x, 3):
    ans += i[0] * i[1] * i[2]
print(ans)
"""

# n <= 10**5
n = int(input())
# vi <= 10**5
v = list(map(int, input().split()))
a = [[0] * 100010 for _ in range(2)]
for i in range(n):
    a[i % 2][v[i]] += 1

od, ev = [], []
for i in range(100010):
    od.append([a[1][i], i])
    ev.append([a[0][i], i])
od.sort()
od.reverse()
ev.sort()
ev.reverse()
if od[0][1] != ev[0][1]: print(n - od[0][0] - ev[0][0])
else: print(n - max(od[0][0] + ev[0][1], od[1][0] + ev[0][0]))

# Fixed code:
import itertools
"""
n = int(input())
m, a, r, c, h = [0] * 5
for i in range(n):
    s = input()
    if s[0] == "M": m += 1
    if s[0] == "A": a += 1
    if s[0] == "R": r += 1
    if s[0] == "C": c += 1
    if s[0] == "H": h += 1
x = [m, a, r, c, h]
y = ["M", "A", "R", "C", "H"]
ans = 0
for i in itertools.combinations(x, 3):
    ans += i[0] * i[1] * i[2]
print(ans)
"""

# n <= 10**5
n = int(input())
# vi <= 10**5
v = list(map(int, input().split()))
a = [[0] * 100010 for _ in range(2)]
for i in range(n):
    a[i % 2][v[i]] += 1

od, ev = [], []
for i in range(100010):
    od.append([a[1][i], i])
    ev.append([a[0][i], i])
od.sort()
od.reverse()
ev.sort()
ev.reverse()
if od[0][1] != ev[0][1]: print(n - od[0][0] - ev[0][0])
else: print(n - max(od[0][0] + ev[1][0], od[1][0] + ev[0][0]))
# Buggy code:
n=int(input())
v=list(map(int, input().split()))
import collections
v1=v[0::2]
v11=collections.Counter(v1)
v2=v[1::2]
v22=collections.Counter(v2)
o=v11.most_common()
e=v22.most_common()
if o[0][0]!=e[0][0] or e==o:
    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]))

# Fixed code:
n=int(input())
v=list(map(int, input().split()))
import collections
v1=v[0::2]
v11=collections.Counter(v1)
v2=v[1::2]
v22=collections.Counter(v2)
o=v11.most_common()+([(0,0)])
e=v22.most_common()+([(0,0)])
if o[0][0]!=e[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]))
# Buggy code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
a = ai()
if all(i == a[0] for i in a):
    print(n//2)
    exit()

a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c1 = Counter(a1)
c2 = Counter(a2)
m1 = c1.most_common(2)
m2 = c2.most_common(2)
if m1[0][0] == m2[0][0]:
    if len(c1) == 1:
        print(n-m1[0][1]-m2[1][1])
    elif len(c2) == 1:
        print(n - m1[0][1] - m2[1][1])
    else:
        print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))
else:
    print(n-m1[0

# Fixed code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
a = ai()
if all(i == a[0] for i in a):
    print(n//2)
    exit()

a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c1 = Counter(a1)
c2 = Counter(a2)
m1 = c1.most_common(2)
m2 = c2.most_common(2)
if m1[0][0] == m2[0][0]:
    if len(c1) == 1:
        print(n-m1[0][1]-m2[1][1])
    elif len(c2) == 1:
        print(n - m1[0][1] - m2[1][1])
    else:
        print(min(n-m1[0][1]-m2[1][1], n-m1[1][1]-m2[0][1]))
else:
    print(n-m1[0][1] - m2[0][1])
# Buggy code:
n = int(input())
a = [int(aa) for aa in input().split()]

def add_entry(hist, aa):
    if aa in hist:
        hist[aa] += 1
    else:
        hist[aa] = 1


def make_hist(a):
    even_hist = {}
    odd_hist = {}

    for i in range(len(a)//2):
        add_entry(even_hist, a[2*i])
        add_entry(odd_hist, a[2*i+1])

    return even_hist, odd_hist


def get_sorted_hist(hist):
    return sorted(hist.items(), key=lambda x: -x[0])


eh, oh = make_hist(a)
seh = get_sorted_hist(eh)
soh = get_sorted_hist(oh)

if seh[0][0] != soh[0][0]
    print(len(a) - seh[0][1] - soh[0][1])
else:
    if seh[0][1] >= soh[0][1]:
        print(len(a) - seh[0][1] - soh[1][1])
    else:
        print(len(a) - seh[1][1] - soh[0][1])


# Fixed code:
n = int(input())
a = [int(aa) for aa in input().split()]

def add_entry(hist, aa):
    if aa in hist:
        hist[aa] += 1
    else:
        hist[aa] = 1


def make_hist(a):
    even_hist = {}
    odd_hist = {}

    for i in range(len(a)//2):
        add_entry(even_hist, a[2*i])
        add_entry(odd_hist, a[2*i+1])

    return even_hist, odd_hist


def get_sorted_hist(hist):
    return sorted(hist.items(), key=lambda x: -x[1])

eh, oh = make_hist(a)
seh = get_sorted_hist(eh)
soh = get_sorted_hist(oh)


if seh[0][0] != soh[0][0]:
    print(len(a) - seh[0][1] - soh[0][1])
else:
    if len(seh) == 1 and len(soh) == 1:
        print(len(a)//2)
    elif len(seh) == 1:
        print(len(a) - seh[0][1] - soh[1][1])
    elif len(soh) == 1:
        print(len(a) - soh[0][1] - seh[1][1])
    else:
        print(min(len(a) - seh[0][1] - soh[1][1], len(a) - soh[0][1] - seh[1][1]))
# Buggy code:
from collections import Counter
n,*v = map(int,open(0).read().split())
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1 = sorted([(i,v1[i]) for i in v1.keys()],key =lambda x:x[1],reverse=True)
v2 = sorted([(i,v2[i]) for i in v2.keys()],key =lambda x:x[1],reverse=True)
print(v1,v2)
if len(v1) == 1:
  if len(v2) == 1:
    if v1[0][0] != v2[0][0]:
      print(0)
    else:
      print(n//2)
  else:
    if v1[0][0] != v2[0][0]:
      print(n//2-v2[0][1])
    else:
      print(n//2-v2[1][1])
else:
  if len(v2) == 1:
    if v1[0][0] != v2[0][0]:
      print(n//2-v1[0][1])
    else:
      print(n//2-v1[1][1])
  else:
    if v1[0][0] != v2[0][0]:
      print(n-v1[0][1]-v2[0][1])
    else:
      print(min(n-v1[0][1]-v2[1][1],n-v1[1][1]-v2[0][1]))

# Fixed code:
from collections import Counter
n,*v = map(int,open(0).read().split())
v1 = Counter(v[::2])
v2 = Counter(v[1::2])
v1 = sorted([(i,v1[i]) for i in v1.keys()],key =lambda x:x[1],reverse=True)
v2 = sorted([(i,v2[i]) for i in v2.keys()],key =lambda x:x[1],reverse=True)
if v1[0][0] != v2[0][0]:
  print(n-v1[0][1]-v2[0][1])
else:
  e1 = n-v2[0][1] if len(v1) == 1 else n-v1[1][1]-v2[0][1]
  e2 = n-v1[0][1] if len(v2) == 1 else n-v1[0][1]-v2[1][1]
  print(min(e1,e2))
# Buggy code:
n = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
import operator
def f():
    evn = Counter(A[::2])
    odd = Counter(A[1::2])

    a = sorted(odd.most_common(2), key=operator.itemgetter(1, 0), reverse=True)
    b = sorted(evn.most_common(2), key=operator.itemgetter(1, 0), reverse=True)

    ac = a[0][1]
    bc = b[0][1]
    ret = n - ac + bc
    if a[0][0] == b[0][0]:
        bc_2 = b[1][1] if len(b) != 1 else 0
        ac_2 = a[1][1] if len(a) != 1 else 0
        ret = n - max(ac + bc_2, ac_2 + bc)
    return ret
print(f())

# Fixed code:
n = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
import operator
def f():
    evn = Counter(A[::2])
    odd = Counter(A[1::2])

    a = sorted(odd.most_common(2), key=operator.itemgetter(1, 0), reverse=True)
    b = sorted(evn.most_common(2), key=operator.itemgetter(1, 0), reverse=True)

    ac = (n // 2) - a[0][1]
    bc = (n // 2) - b[0][1]
    ret = ac + bc
    if a[0][0] == b[0][0]:
        bc_2 = n // 2 - (b[1][1] if len(b) != 1 else 0)
        ac_2 = n // 2 - (a[1][1] if len(a) != 1 else 0)
        ret = min(ac + bc_2, ac_2 + bc)
    return ret
print(f())
# Buggy code:
import collections


n = int(input())
odd = []
even = []
for i,j in enumerate(map(int,input().split())):
    if i % 2 == 0:
        even += [j]
    else:
        odd += [j]
odd = sorted(collections.Counter(odd).items(),key=lambda x:(x[1]),reverse=True)
even = sorted(collections.Counter(even).items(),key=lambda x:(x[1]),reverse=True)

if len(odd) == 1 and len(even) == 1:
    if odd[0][0] == even[0][0]:
        print(n//2)
    else:
        print(0)
elif len(odd) == 1 or len(even) == 1:
    if len(odd) == 1:
        print((n//2 - odd[0][1]) + (n//2 - even[1][1]))
    elif len(even) == 1:
        print((n//2 - odd[1][1]) + (n//2 - even[1][1]))
else:
    if odd[0][1] + even[1][1] > odd[1][1] + even[0][1]:
        print((n//2 - odd[0][1]) + (n//2 - even[1][1]))
    else:
        print((n//2 - odd[1][1]) + (n//2 - even[0][1]))

# Fixed code:
import collections


n = int(input())
odd = []
even = []
for i,j in enumerate(map(int,input().split())):
    if i % 2 == 0:
        even += [j]
    else:
        odd += [j]
odd = sorted(collections.Counter(odd).items(),key=lambda x:(x[1]),reverse=True)
even = sorted(collections.Counter(even).items(),key=lambda x:(x[1]),reverse=True)

if len(odd) == 1 and len(even) == 1:
    if odd[0][0] == even[0][0]:
        print(n//2)
        exit()
    else:
        print(0)
        exit()

if odd[0][0] == even[0][0]:
    if len(odd) >= 2 and len(even) >= 2:
        if odd[0][1] + even[1][1] > odd[1][1] + even[0][1]:
            print((n//2 - odd[0][1]) + (n//2 - even[1][1]))
        else:
            print((n//2 - odd[1][1]) + (n//2 - even[0][1]))
    else:
        if len(odd) == 1:
            print((n//2 - odd[0][1]) + (n//2 - even[1][1]))
        else:
            print((n//2 - odd[1][1]) + (n//2 - even[0][1]))
else:
    print((n//2 - odd[0][1]) + (n//2 - even[0][1]))
# Buggy code:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))

A=v[0::2]
B=v[1::2]
a=len(A)
b=len(B)

#print(Counter(A).most_common()[0][0])
#print(Counter(B).most_common()[0][0])

if Counter(A).most_common()[0][0] !=Counter(B).most_common()[0][0]:
    s=Counter(A).most_common()[0][1]
    t=Counter(B).most_common()[0][1]
    print( (a-s)+(b-t))
else:
    o=Counter(A).most_common()[1][1]
    p=Counter(B).most_common()[0][1]
    r= (a-o)+(b-p)
    w=Counter(A).most_common()[0][1]
    x=Counter(B).most_common()[1][1]
    s= (a-w)+(b-x)
    print(min( r, s))


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

A=v[0::2]
B=v[1::2]
a=len(A)
b=len(B)

#print(Counter(A).most_common()[0][0])
#print(Counter(B).most_common()[0][0])

if Counter(A).most_common()[0][0] !=Counter(B).most_common()[0][0]:
    s=Counter(A).most_common()[0][1]
    t=Counter(B).most_common()[0][1]
    print( (a-s)+(b-t))
else:
  r=a
  s=b
  if Counter(A).most_common()[0][1]<a:
    o=Counter(A).most_common()[1][1]
    p=Counter(B).most_common()[0][1]
    r= (a-o)+(b-p)
  if Counter(B).most_common()[0][1]<b:
    w=Counter(A).most_common()[0][1]
    x=Counter(B).most_common()[1][1]
    s= (a-w)+(b-x)
  print(min( r, s))
# Buggy code:
import collections

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

eNum=collections.Counter(r[1::2])
oNum=collections.Counter(r[::2])


if eNum.keys()[0]==oNum.keys()[0]:
  print(len(r)-max(eNum[eNum.keys()[0]]+oNum[oNum.keys()[1]],eNum[eNum.keys()[1]]+oNum[oNum.keys()[0]]))
else:
  print(len(r)-eNum[eNum.keys()[0]]-oNum[oNum.keys()[1]])

# Fixed code:
import collections

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

eNum=collections.Counter(r[1::2]).most_common()
oNum=collections.Counter(r[::2]).most_common()
eNum.append((0,0))
oNum.append((0,0))



if eNum[0][0]==oNum[0][0]:
  print(len(r)-max(eNum[0][1]+oNum[1][1],eNum[1][1]+oNum[0][1]))
else:
  print(len(r)-eNum[0][1]-oNum[0][1])