#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sz(v) (int)v.size()
typedef long long LL;
typedef double db;
template<class T>bool ckmax(T&x,T y){return x<y?x=y,1:0;}
template<class T>bool ckmin(T&x,T y){return x>y?x=y,1:0;}
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define per(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
const int N=100005;
int n,a[N],lst[N],nxt[N],i1,i2,ans,b[N],tot,num[N],c[N];
signed main(){
	n=read();
	rep(i,1,n)a[i]=read();
	for(int i=1;i<=n;){
		int j=i-1;
		while(j<n&&a[j+1]==a[i])++j;
		b[++tot]=a[i],num[tot]=j-i+1,i=j+1;
	}
	per(i,tot,1)nxt[i]=lst[b[i]],lst[b[i]]=i;
	// rep(i,1,tot)cerr<<nxt[i]<<' ';cerr<<'\n';
//	rep(i,1,tot)cerr<<b[i]<<' ';cerr<<'\n';
//	rep(i,1,tot)cerr<<num[i]<<' ';cerr<<'\n';
	for(int i=1;i<=tot;++i){
		if(b[i1]==b[i]||b[i2]==b[i]){
			if(b[i1]==b[i])i1=i;
			else i2=i;
		}else{
			if(!nxt[i1])i1=i,++ans;
			else if(!nxt[i2])i2=i,++ans;
			else (nxt[i1]<=nxt[i2]?i2=i:i1=i),++ans;
		}
//		cerr<<i<<' '<<i1<<' '<<i2<<'\n';
	}
	cout<<ans<<'\n';
}