#include<bits/stdc++.h>
#define il inline
#define re register
using namespace std;
int n,ans,sum1,sum2,a[200005],to[200005],lst[200005];
int main(){
    cin>>n,to[0]=n<<1;
    for(re int i=1;i<=n;++i)cin>>a[i];
    for(re int i=1;i<=n;++i)lst[a[i]]=n+1;
    for(re int i=n;i;--i)to[i]=lst[a[i]],lst[a[i]]=i;
    for(re int i=1;i<=n;++i)
        if(a[i]!=a[sum1]&&a[i]!=a[sum2])++ans,to[sum1]>to[sum2]?sum1=i:sum2=i;
        else if(a[i]==a[sum1])sum1=i;
        else if(a[i]==a[sum2])sum2=i;
        else sum1=sum2=i;
    cout<<ans;
}