#include <bits/stdc++.h>
using namespace std;
long long n, s;
long long a[200005];
long long cnt[200005];
int main() {
  cin >> n >> s;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (i != s) cnt[a[i]]++;
  }
  if (n == 1) {
    if (a[1] == 0)
      cout << "0\n";
    else
      cout << "1\n";
    return 0;
  }
  long long csum = 0;
  long long blanks = 0;
  ans = 1e15;
  for (long long height = 1; height < n; height++) {
    csum += cnt[height];
    if (cnt[height] == 0) blanks++;
    ans = min(ans, max(n - csum - 1, blanks));
  }
  if (a[s] != 0) ans++;
  cout << ans << endl;
  return 0;
}
