#include<bits/stdc++.h>
#define pb emplace_back
#define AI(i) begin(i), end(i)
using namespace std;
using ll = long long;
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() {cerr << endl;}
template<class T, class ...U> void kout (T v, U ...e) { cerr << v << ' ', kout(e...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L)==R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
// What I should check
// 1. overflow
// 2. corner cases
// Enjoy the problem instead of hurrying to AC
// Good luck !
const int MAX_N = 300010;

set<pair<int,int>> st;
vector<int> pos[MAX_N];
int n, a[MAX_N], nxt[MAX_N];

int have[MAX_N];
void putin(int id, int d) {
	have[id] += d;
	if (d == 1)
		st.insert({nxt[id], id});
	else
		st.erase({nxt[id], id});
}
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n ;
	for (int i = 0;i < n;++i)
		cin >> a[i];
	for (int i = 1;i <= n;++i) pos[i].pb(n);
	for (int i = n-1;i >= 0;--i)
		pos[ a[i] ].pb(i);

	for (int i = 1;i <= n;++i)
		nxt[i] = pos[i].back();

	nxt[n+1] = nxt[0] = n + 10;

	putin(0, 1), putin(n+1, 1);

	int res = 0;
	for (int i = 0;i < n;++i) {
		DE(i, a[i], have[1], have[2]);
		if (have[ a[i] ]) 
			putin(a[i], -1);
		else {
			DE(i);
			++res;
			auto [t, id] = *prev(st.end());
			putin(id, -1);
		}

		pos[ a[i] ].pop_back();
		nxt[ a[i] ] = pos[ a[i] ].back();
		putin(a[i], 1);
	}
	cout << res << '\n';
}
