func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 1;   const int N = 200123;   int z, n, s;   deque<int> dq;   int t[N];   int main() {     ios_base::sync_with_stdio(0);     int ans = 0;     cin >> n >> s;     for (int i = 0; i < n; i++) {       cin >> t[i];       if (i + 1 == s) {         ans += (t[i] != 0);         n--;         i--;         s = inf;       } else if (t[i] == 0)         t[i] = n + 5;     }     sort(t, t + n);     for (int i = 0; i < n; i++) {       dq.push_back(t[i]);     }     int nxt = 1;     while (dq.size()) {       while (dq.size() && nxt < dq.front()) {         dq.pop_back();         nxt++;         ans++;       }       if (dq.size()) {         nxt = max(nxt, dq.front() + 1);         dq.pop_front();       }     }     cout << ans << endl;   }   