func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 101010 * 2;   vector<int> vec[maxn];   vector<int> mp[maxn];   bool vis[maxn];   int arr[maxn];   int dfs(int x) {     vis[x] = true;     int ans = vec[x].size();     int siz = mp[x].size();     for (int i = 0; i < siz; i++) {       int y = mp[x][i];       if (vis[y]) continue;       ans = max(ans, dfs(y));     }     return ans;   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       vec[arr[i]].push_back(i);     }     int ans = 0, las = 0, pos = 0;     int maxv = 0;     for (int i = 1; i <= n; i++) {       if (las != arr[i] && las) {         if (vec[arr[i]][0] < pos || maxv > i)           mp[arr[i]].push_back(las), mp[las].push_back(arr[i]);       }       las = arr[i], pos = i;       int siz = vec[arr[i]].size();       maxv = max(maxv, vec[arr[i]][siz - 1]);     }     for (int i = 1; i <= n; i++) {       if (vis[i]) continue;       ans += dfs(i);     }     printf( %d n , n - ans);   }   