#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e9;
const long long N = 1e6;
long long a[N], cnt[N], cnts[N], sum[N];
int32_t main() {
  long long n, s;
  cin >> n >> s;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  bool root = false;
  long long ans = oo;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (a[s]) {
    root = true;
    a[s] = 0;
  }
  for (long long i = 1; i <= n; i++)
    if (!cnt[a[i]]) cnt[a[i]] = 1;
  for (long long i = 1; i <= n; i++) sum[a[i]]++;
  for (long long i = 0; i <= n - 1; i++) cnts[i] = cnts[i - 1] + cnt[i];
  for (long long i = 0; i <= n - 1; i++) sum[i] += sum[i - 1];
  for (long long h = 1; h <= n - 1; h++) {
    long long empty = h + 1 - cnts[h];
    long long ch = sum[n - 1] - sum[h] + sum[0] - 1;
    ans = min(ans, ch + root + max(0LL, empty - ch));
  }
  cout << ans << endl;
}
