#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
signed main() {
  long long n, s, w = 0, a, cnt = 0;
  cin >> n >> s;
  for (long long i = 1; i <= n; i++) {
    cin >> a;
    v.push_back(a);
    if (a == 0 && i != s) {
      w++;
      v.pop_back();
    }
    if (a != 0 && i == s) {
      cnt++;
      v.pop_back();
    }
  }
  cnt += w;
  sort(v.begin(), v.end());
  long long tem = 1, x = 0;
  while (x < v.size()) {
    if (v[x] > tem) {
      if (w > 0) {
        w--;
      } else {
        v.pop_back();
        cnt++;
      }
      x--;
      tem++;
    } else if (v[x] == tem) {
      tem++;
    }
    x++;
  }
  cout << cnt;
}
