#include <bits/stdc++.h>
/*#ifndef LOCAL_RUN
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC optimize("fast-math")
    #pragma GCC target("avx2,tune=native")
#endif*/
#define fr first
#define sc second
#define m_p make_pair
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int N = 1e5 + 10;

//int cnt[N];

int main()
{
    #ifdef LOCAL_RUN
        freopen("input.txt", "r", stdin);
    #else
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios::sync_with_stdio(false);
        cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> idx(n+1);
    for (int& it: a) {
        cin >> it;
        //cnt[it]++;
    }
    for (int i = n-1; i >= 0; i--)
        idx[a[i]].push_back(i);

    int ans = 0, lst[2] = {0, 0};
    for (int it: a) {
        idx[it].pop_back();
        if (lst[0] == it || lst[1] == it)
            continue;
        ++ans;
        int t1 = idx[lst[0]].empty() ? n + 228 : idx[lst[0]].back(),
            t2 = idx[lst[1]].empty() ? n + 228 : idx[lst[1]].back();
        if (t2 > t1)
            lst[1] = it;
        else
            lst[0] = it;
    }
    cout << ans;

    return 0;
}
