#include <bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> v(n+1);
	vector<int> w[n+1];
	vector<int> pos(n+1, 0);
	int a=0, b=0;
	for(int i=1;i<=n;++i){
		cin>>v[i];
		w[v[i]].push_back(i);
	}
	int sol=0;
	for(int i=1;i<=n;++i){
		if(v[i]==a||v[i]==b) sol--;
		else{
			int na=1<<30, nb=1<<30;	
			while(pos[a]<w[a].size()&&i>=w[a][pos[a]]) ++pos[a];
			if(pos[a]!=w[a].size()) na=w[a][pos[a]];
			while(pos[b]<w[b].size()&&i>=w[b][pos[b]]) ++pos[b];
			if(pos[b]!=w[b].size()) nb=w[b][pos[b]];
			if(na>nb) a=v[i];
			else b=v[i];
		}
		sol++;
	}
	cout<<sol<<"\n";
	return 0;
}

