func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int MOD = 1e9 + 7;   const long long M = 1e18;   long long qpow(long long a, long long b, long long m) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % m;       b /= 2;       a = (a * a) % m;     }     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) {       int n, q;       cin >> n >> q;       int a[n + 1];       map<int, int> mn, mx, ct;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (mn[a[i]] == 0) mn[a[i]] = i;         mx[a[i]] = i;         ct[a[i]]++;       }       int l = 1, r = 1;       int ans = 0;       for (int i = 1; i <= n; i++) {         r = max(r, mx[a[i]]);         if (i == r) {           int ans1 = N;           for (int j = l; j <= r; j++) {             ans1 = min(ans1, (r - l + 1) - ct[a[j]]);           }           ans += ans1;           l = r + 1;           r++;         }       }       cout << ans;     }   }   