#include <bits/stdc++.h>
using namespace std;
long long a[200010];
int main() {
  memset(a, 0, sizeof(a));
  long long n, s;
  long long x, carry = 0, mx = 0, pre = 0;
  scanf("%lld %lld", &n, &s);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &x);
    if (i == s)
      carry = x ? 1 : 0;
    else if (x >= n)
      pre++;
    else
      a[x]++;
  }
  long long emp = 0, ans = n;
  for (long long i = 1; i <= n - 1; i++)
    if (a[i] == 0) emp++;
  pre += a[0];
  for (long long i = n - 1; i >= 1; i--) {
    ans = min(ans, max(pre, emp));
    if (a[i])
      pre += a[i];
    else
      emp--;
  }
  if (n == 1) ans = 0;
  ans += carry;
  printf("%lld\n", ans);
  return 0;
}
