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

vector<int> a;
vector<int> indx[100005];

const int INF = 1012345678;

int prev1[2];

int main(){
    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i ++){
        int x;
        scanf("%d", &x);
        a.push_back(x);
    }

    a.erase(unique(a.begin(), a.end()), a.end());

    int m = (int)a.size();
    for(int i = 0; i < m; i ++){
        indx[a[i]].push_back(i);
    }
    for(int i = 1; i <= n; i ++){
        indx[i].push_back(INF);
    }

    int ans = 0;

    memset(prev1, -1, sizeof(prev1));
    for(int i = 0; i < m; i ++){
        if(a[i] == prev1[0] || a[i] == prev1[1]){
            continue;
        }
        if(prev1[0] == -1){
            ans ++;
            prev1[0] = a[i];
            continue;
        }
        if(prev1[1] == -1){
            ans ++;
            prev1[1] = a[i];
            continue;
        }
        int nextIndx0 = *lower_bound(indx[prev1[0]].begin(), indx[prev1[0]].end(), i+1);
        int nextIndx1 = *lower_bound(indx[prev1[1]].begin(), indx[prev1[1]].end(), i+1);
        if(nextIndx0 < nextIndx1){
            ans ++;
            prev1[1] = a[i];
        }else{
            ans ++;
            prev1[0] = a[i];
        }
    }

    printf("%d\n", ans);
    return 0;
}
