#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <ctime>
#include <random>
#include <chrono>
#define rep(i,j,k) for(int i = j; i <= k; i++) 
#define dow(i,j,k) for (int i = j; i >= k; i--)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;

const int N = 100005;
int nxt[N], pos[N];
int n, a[N];
int ans;

int main() {
    scanf("%d", &n);
    rep(i,0,n) pos[i] = n + 1;
    rep(i,1,n) scanf("%d", &a[i]);
    dow(i,n,0) {
        nxt[i] = pos[a[i]];
        pos[a[i]] = i;
    }
    int x = 0, y = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == a[x]) x = i;
        else if (a[i] == a[y]) y = i;
        else {
            ans++;
            if (nxt[x] > nxt[y]) x = i;
            else y = i;
        }
    }
    cout << ans << endl;
}
            
