#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &it:a) cin >> it;
    vector<pair<int,pair<int,int>>> occ;
    int c = 0,v = a[0];
    for(int i = 0; i<n; i++){
        if(v!=a[i]){
            occ.push_back({v,{c,i-c}});
            v = a[i];
            c = 0;
        }
        c++;
    }
    occ.push_back({v,{c,n-c}});
    int osz = occ.size();
    int ans = occ.size();
    int v0 = -1, v1 = -1,buf = -1;
    int bstart = 0;
    vector<int> l(n+1,-1);
    for(int i = 0; i<osz; i++){
        int val = occ[i].first;
        int cnt = occ[i].second.first;
        int ix = occ[i].second.second;
        if(val==v0){
            ans--;
            if(buf!=-1){
                //if(i==osz-1)
                 //   ans--;
                v1 = buf;
                buf = -1;
                bstart = i+1;
            }
        }else if(val==v1){
            ans--;
            if(buf!=-1){
                //if(i==osz-1)
                //    ans--;
                v0 = buf;
                buf = -1;
                bstart = i+1;
            }
        }
        else if(l[val]>=bstart){
            v0 = val;
            v1 = buf;
            bstart = i+1;
            buf = -1;
            ans--;
        }else{
            buf = val;
        }
        l[val] = i;
    }
    cout << ans << endl;
    return 0;
}