#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;

int a[maxn];
int f[maxn];
int n,m,gcnt,ans;

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),f[i]=n+1;
	gcnt=1;
	for (int i=2,prevmin=0;i<=n;i++)
	{
		if (a[i-1]!=a[i]) gcnt++;
		f[a[i-1]]=min(f[a[i]]-1+(a[i-1]==a[i]),prevmin);
		prevmin=min(prevmin,f[a[i-1]]);
	}
	ans=n;
	for (int i=0;i<=n;i++) ans=min(ans,f[i]+gcnt);
	printf("%d\n",ans);
}

