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

#define sz(a) int(a.size())
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int comp (VI a) {
	int n = sz(a);
	VVI f (n, VI (1, INT_MAX));
	for (int &t : a) t--;
	for (int i = n-1; i >= 0; i--) f[a[i]].push_back(i);


	vector <int> ra, rb;
	for (int i = 0; i < n; i++) {
		f[a[i]].pop_back();

		bool ca = ra.empty() || ra.back() != a[i];
		bool cb = rb.empty() || rb.back() != a[i];

		if (ca && cb) {
			int pa = INT_MAX, pb = INT_MAX;
			if (!ra.empty()) pa = f[ra.back()].back();
			if (!rb.empty()) pb = f[rb.back()].back();

			(pa > pb ? ra : rb).push_back(a[i]);
		} else if (!cb) {
			rb.push_back(a[i]);
		} else ra.push_back(a[i]);
	}

	ra.resize(unique(ra.begin(), ra.end())-ra.begin());
	rb.resize(unique(rb.begin(), rb.end())-rb.begin());

	return sz(ra) + sz(rb);
}

int main(){
	int n;
	cin >> n;

	VI a(n);
	for (int &t : a) cin >> t;
	cout << comp(a) << endl;
}
