/*
 * @Author: zhl
 * @LastEditTime: 2021-02-08 21:20:19
 */
 /* Author: zhl
  * Time: 2021-02-07 22:35:03
 **/

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

const int N = 2e5 + 10;
typedef long long ll;

int n, A[N], vis[N], B[N], pre[N], f[N], mx[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    int cnt = 0;
    int ppre = 0;
    int ans = n;
    for (int i = 1; i <= n; i++) {
        if (A[i] == ppre) {
            vis[cnt] = 1;
            ans--;
        }
        else {
            B[++cnt] = A[i];
        }
        ppre = A[i];
    }
    // for(int i = 1;i <= cnt;i++){
    //     cout << B[i] << " " << vis[i] <<  endl;
    // }

    for (int i = 1;i <= cnt;i++) {
        if (pre[B[i]]) {
            int p = pre[B[i]];
            f[i] = max(f[i],mx[p + 1] + 1);
        }

        pre[B[i]] = i;
        mx[i] = max(mx[i-1],f[i]);
    }
    ans -= mx[cnt];
    cout << ans << endl;
}


