func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int a[N];   vector<int> v;   int main() {     int n, s;     scanf( %d%d , &n, &s);     int ans = 0;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     if (a[s] != 0) ans++;     for (int i = 1; i <= n; i++)       if (i == s)         continue;       else         v.push_back(a[i]);     v.push_back(0);     sort(v.begin(), v.end());     int cnt = 0;     int idx = 0;     while (v[idx] == 0 && idx < n) cnt++, idx++;     ans += cnt;     cnt--;     ans--;     int last = n - 1;     for (int i = idx; i <= last; i++) {       if (i == 0) continue;       if (v[i] == v[i - 1]) continue;       if (v[i - 1] == v[i] - 1) continue;       int diff = v[i] - v[i - 1] - 1;       if (diff <= cnt) {         cnt -= diff;         continue;       }       diff -= cnt;       cnt = 0;       while (diff--) {         if (last >= i) {           last--;           ans++;           continue;         }         if (last <= i) break;       }     }     cout << ans << endl;     return 0;   }   