#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const int N = 1e5+5;
int a[N];
deque<int> q;
int num;
int main()
{
    ios::sync_with_stdio(0);
    int n;cin>>n;
    rep(i,1,n){
        cin>>a[i];
    }
    q.push_back(a[1]);++num;
    rep(i,2,n){

        // cout<<"t"<<i-1<<":";
        // rep(i,1,num){
        //     cout<<q[i-1]<<' ';
        // }
        //cout<<endl;
        int idx = upper_bound(q.begin(),q.end(),a[i],greater<int>())-q.begin();
        //cout<<"idx:"<<idx<<endl;
        if(idx==num){
            q.push_back(a[i]);
            ++num;
        }else{
            q[idx] = a[i];
        }
        //sort(q.begin(),q.end(),greater<int>());
    }
    cout<<num;
    
}

#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define N 100100

lli n;

int main(void){
	cin >> n;
	vector<lli> v(n);
	vector<lli> e(N), o(N);
	rep(i, n) cin >> v[i];
	rep(i, n){
		if(i%2 == 0){
			e[v[i]]++;
		}else{
			o[v[i]]++;
		}
	}
	auto p1 = max_element(e.begin(), e.end())-e.begin();
	auto p2 = max_element(o.begin(), o.end())-o.begin();
	if(p1 != p2){
		cout << n-e[p1]-o[p2] << endl;
	}else{
		sort(e.rbegin(), e.rend());
		sort(o.rbegin(), o.rend());
		cout << n-max(e[0]+o[1], e[1]+o[0]) << endl;
	}

	return 0;
}
