#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	int ans = 0;
	cin >> n;
	int v;
	pair<Pi, Pi> as = mp(mp(0, 0), mp(0, 0));
	pair<Pi, Pi> bs = mp(mp(0, 0), mp(0, 0));
	pair<map<int, int>, map<int, int>> dis;
	rep(i, n) {
		cin >> v;
		if (i % 2) {
			dis.F[v]++;
		} else {
			dis.S[v]++;
		}
	}
	repi(itr, dis.F) {
		if (itr->S > as.F.S) {
			as.S = as.F;
			as.F = *itr;
		} else if (itr->S > as.S.S) {
			as.S = *itr;
		}
	}
	repi(itr, dis.S) {
		if (itr->S > bs.F.S) {
			bs.S = bs.F;
			bs.F = *itr;
		} else if (itr->S > bs.S.S) {
			bs.S = *itr;
		}
	}
	if (as.F.F != bs.F.F) {
		ans = n - as.F.S - bs.F.S;
	} else {
		ans = n - max(as.F.S + bs.S.S, as.S.S + bs.F.S);
	}

	cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int D;
ll kotae = 0;
void keisan(ll A, int B, int C, vector<int> V) {
	if (B < C / 2) {
		ll k1 = 1, k2 = 1;
		rep(i, C - B - 1) k1 *= 10;
		rep(i, B) k2 *= 10;
		ll k = k1 - k2;
		if (A >= 0) {
			if (abs(A / k) < 10) {
				V.pb(A / k);
				keisan(A % k, B + 1, C, V);
				V.pop_back();
			}
			if (abs(A / k + 1) < 10) {
				V.pb(A / k + 1);
				keisan(A % k - k, B + 1, C, V);
			}
		}
		else {
			if (abs(A / k) < 10) {
				V.pb(A / k);
				keisan(A % k, B + 1, C, V);
				V.pop_back();
			}
			if (abs(A / k - 1) < 10) {
				V.pb(A / k - 1);
				keisan(A % k + k, B + 1, C, V);
			}
		}
	}
	else {
		if (A == 0) {
			ll kari = 1;
			rep(j, V.size()) {
				int kari2 = 0;
				if (j == 0) {
					rep1(k, 9) {
						if (k + V[j] < 10) kari2++;
					}
				}
				else {
					rep(k, 10) {
						if (k + V[j] >= 0 && k + V[j] < 10) kari2++;
					}
				}
				kari *= kari2;
			}
			if (C % 2) kari *= 10;
			kotae += kari;
		}
	}
}



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> D;

	for (int i = 19; i >= 2; i--) {
		vector<int> V;
		keisan(D, 0, i, V);
	}

	co(kotae);

	Would you please return 0;
}