#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
const long long p = 998244353;
long long qp(long long x, long long y) {
  long long res = 1;
  for (long long t = x; y; y >>= 1, t = t * t % p)
    if (y & 1) res = res * t % p;
  return res;
}
long long n = read(), s = read();
long long a[1000003];
long long pre[1000003];
signed main() {
  long long F = 0;
  for (long long i = 1; i <= n; ++i)
    if (i != s) {
      long long x = read();
      if (x == 0) x = n + 1;
      ++a[x];
    } else {
      long long x = read();
      if (x != 0) F = 1;
    }
  pre[0] = a[0] = 1;
  for (long long i = 1; i <= n; ++i) pre[i] = pre[i - 1] + a[i];
  long long ans = 9999999;
  for (long long i = 0, s = 0; i <= n; ++i) {
    s += (a[i] == 0);
    ans = min(ans, max(s, n - pre[i]));
  }
  printf("%lld\n", ans + F);
  return 0;
}
