#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int maxn = 1e6 + 10;

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 5);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	vector<queue<int>> q(n + 1);
	int x = 0, y = 0;
	int ans = 0;
	q[0].push(int(1e9));
    q[0].push(int(1e9));
	for (int i = 1; i <= n; i++) {
		q[a[i]].push(i);
	}
	for (int i = 1; i <= n; i++) q[i].push((int)1e9);
	for (int i = 1; i <= n; i++) {
		// cout << ans << '\n';
		if (x == a[i] && y == a[i]) {
			assert(0);
		}
		else if (x == a[i] || y == a[i]) {
			q[a[i]].pop();
		}
		else {
			int nx = q[x].front(), ny = q[y].front();
            // printf("xy %d %d\n", x, y);
			if (nx > ny)
				x = a[i];
			else
				y = a[i];
			q[a[i]].pop();
            ans++;
		}
	}
	cout << ans;
}