#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int N = 1e5+7;
vector<int> adj[N];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;
  for (int i = n-1; i >= 0; i--) 
    adj[a[i]].push_back(i);
  int b = 0, w = 0;
  int ans =0;
  for (int i = 0; i < n; i++) { 
    int c = a[i];
    adj[c].pop_back();
    if (c == b || c==w) continue;
    int nxtw, nxtb;
    if (adj[b].size() == 0) nxtb = -1;
    else
      nxtb = adj[b].back();
    if (adj[w].size() == 0) nxtw = -1;
    else nxtw = adj[w].back();

    if (nxtb == -1) 
    {
      b = c;
      ans++;
    }
    else if (nxtw == -1) {
      w = c;
      ans++;
    }
    else if (nxtb < nxtw) {
      w = c;
      ans++;
    }
    else
    {
      b = c;
      ans++;
    }
  }
  cout << ans << '\n';
}

// At any given time, accumulate one type on white and do whatever with black
//
// If not acc. on both, add to the other.
// If we are, then I have to chuck out 1! How to choose?


