#include <bits/stdc++.h>

using namespace std;

typedef int int2;
#define int long long
#define pi pair<int, int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
const int inf = 1e18;

int t;

const int maxn = 1e5 + 5;
int dp[maxn];
int last[maxn];
int cur_occ[maxn];
int n;

int2 main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    memset(last, -1, sizeof(last));
    memset(cur_occ, -1, sizeof(cur_occ));
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    a.erase(unique(a.begin(), a.end()), a.end());
    n = (int)a.size() - 1;
    // cout << "n: " << n << "\n";
    for (int i = 1; i <= n; i++) {
        dp[i] = inf;
        assert(dp[i] == inf);
    }
    cur_occ[a[1]] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        assert(dp[i] == inf);
        if (~cur_occ[a[i]]) {
            int idx = cur_occ[a[i]];
            dp[i] = dp[idx + 1] + ((i - 1) - (idx + 1));
        }
        // cout << "i: " << i << ", dp[i]: " << dp[i] << "\n";
        dp[i] = min(dp[i], dp[i - 1] + 1);
        cur_occ[a[i]] = i;
        // cout << "i: " << i << ", dp: " << dp[i] << "\n";
    }
    cout << dp[n] << "\n";
} 