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