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

int main(){
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n; cin >> n;
  vector<int> a(n), oc[n + 1];
  for(int i = 0; i < n; i ++){
    cin >> a[i];
    oc[a[i]].push_back(i);
  }
  int x = 0, y = 0, ans = 0;
  for(int i = 0; i < n; i ++){
    if(a[i] == x || a[i] == y)
      continue;
    int n1 = (upper_bound(oc[x].begin(), oc[x].end(), i) - oc[x].begin());
    int n2 = (upper_bound(oc[y].begin(), oc[y].end(), i) - oc[y].begin());
    if(n1 >= oc[x].size())
      n1 = n + 1;
    else
      n1 = oc[x][n1];
    if(n2 >= oc[y].size())
      n2 = n + 1;
    else
      n2 = oc[y][n2];
    if(n1 >= n2)
      ans ++, x = a[i];
    else
      ans ++, y = a[i];
  }
  cout << ans;
}
