func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7, inf = 1061109567;   const long long infll = 4557430888798830399;   const int N = 2e5 + 5;   int n, q, a[N], cnt[N];   bool last[N], first[N];   vector<int> app[N];   bool start[N];   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) app[a[i]].push_back(i);     for (int i = 0; i < N; i++)       if (app[i].size()) {         first[app[i][0]] = 1;         last[app[i].back()] = 1;       }     int thing = 0;     memset(start, 0, sizeof start);     start[0] = 1;     for (int i = 0; i < n; i++) {       if (first[i]) thing++;       if (last[i]) thing--;       if (!thing) start[i + 1] = 1;     }     int ans = 0;     int cur = 0;     while (cur < n) {       int nxt = n - 1;       for (int i = cur + 1; i < n; i++)         if (start[i]) {           nxt = i - 1;           break;         }       int lolMax = 0;       for (int i = cur; i < nxt + 1; i++) {         cnt[a[i]]++;         lolMax = max(lolMax, cnt[a[i]]);       }       ans += lolMax;       for (int i = cur; i < nxt + 1; i++) cnt[a[i]]--;       cur = nxt + 1;     }     cout << n - ans;     return 0;   }   