func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace std {   template <typename T, typename U>   struct hash<pair<T, U>> {     hash<T> t;     hash<U> u;     size_t operator()(const pair<T, U>& p) const {       return t(p.first) ^ (u(p.second) << 7);     }   };   }  // namespace std   template <typename T, typename F>   T bsh(T l, T h, const F& f) {     T r = -1, m;     while (l <= h) {       m = (l + h) / 2;       if (f(m)) {         l = m + 1;         r = m;       } else {         h = m - 1;       }     }     return r;   }   template <typename T, typename F>   T bsl(T l, T h, const F& f) {     T r = -1, m;     while (l <= h) {       m = (l + h) / 2;       if (f(m)) {         h = m - 1;         r = m;       } else {         l = m + 1;       }     }     return r;   }   template <typename T>   T gcd(T a, T b) {     if (a < b) swap(a, b);     return b ? gcd(b, a % b) : a;   }   int main(int, char**) {     ios_base::sync_with_stdio(false);     int N;     cin >> N;     ;     int S;     cin >> S;     ;     vector<int> A(N);     for (auto& _cinv : A) cin >> _cinv;     ;     int err = 0;     if (A[S - 1] != 0) {       ++err;       A[S - 1] = 0;     }     vector<int> Q(N, 0);     for (int i = 0; i < N; i++) {       Q[A[i]]++;     }     int i = 1;     for (; i < N && (Q[0] > 1 || Q[i] > 0); ++i) {       if (Q[i] == 0) {         --Q[0];         ++Q[i];         ++err;       }     }     int j = N - 1;     while (i < j) {       if (Q[j] == 0)         --j;       else if (Q[i] > 0)         ++i;       else {         Q[i]++;         Q[j]--;         err++;       }     }     cout << err << endl;   }   