#include <bits/stdc++.h>
using namespace std;
const int MXN = 200010;
int n, s, p;
int a[MXN], ans, tot, cnt[MXN], sum[MXN];
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (!a[i]) {
      if (i != s) {
        a[i] = n;
      }
    }
  }
  p = a[s] != 0;
  ans = n;
  a[s] = 0;
  for (int i = 1; i <= n; ++i) {
    cnt[a[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + !cnt[i];
  }
  for (int i = n - 1; i >= 0; --i) {
    ans = min(ans, max(cnt[i + 1], sum[i]));
    cnt[i] += cnt[i + 1];
  }
  cout << ans + p << endl;
  return 0;
}
