#include <bits/stdc++.h>
using namespace std;
long long m, n, x, y, z, ans, zeros, s;
long long ara[300000];
multiset<long long> ss;
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &ara[i]);
    if (i == s && ara[i] != 0) {
      ans++;
      ss.insert(0);
      continue;
    }
    if (ara[i] == 0) {
      if (i != s) {
        ss.insert(n);
        continue;
      }
    }
    ss.insert(ara[i]);
  }
  long long curr = 0;
  ans += zeros;
  multiset<long long>::iterator it = ss.begin();
  while (it != ss.end()) {
    if (*it == curr) {
      it++;
      continue;
    }
    if (*it == curr + 1) {
      it++;
      curr++;
      continue;
    }
    multiset<long long>::iterator it1 = ss.end();
    it1--;
    if (it == it1) {
      it = ss.end();
    }
    ss.erase(it1);
    ans++;
    curr++;
  }
  cout << ans << endl;
  return 0;
}
