func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k;     cin >> n >> k;     k--;     vector<int> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     int res = 0;     if (a[k] != 0) {       res++;       a[k] = 0;     }     for (int i = 0; i < n; i++) {       if (i == k) continue;       if (a[i] == 0) a[i] = n;     }     sort(a.begin(), a.end());     int gap = 0;     int ind = 0;     int prev = 0;     int te = n;     for (int i = 0; i < n; i++) {       while (ind < n && a[ind] <= i) {         ind++;         if (ind == n || a[ind] > i) break;         gap += max(0, a[ind] - a[ind - 1] - 1);       }       ind--;       int wrong = n - ind - 1;       te = min(te, max(wrong, gap));     }     if (n > 1) res += te;     cout << res <<   n ;     return 0;   }   