#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, N = 1e6 + 5, mod = 1e9 + 7;
int n, s, cnt[N], z[N], all[N], x, ans, hv, zero, ret = OO;
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (i == s)
      ans += (x != 0), ++cnt[0];
    else if (x == 0)
      ++hv;
    else
      ++cnt[x];
  }
  ans += hv;
  for (int i = 1; i < n; ++i) {
    zero += (cnt[i] == 0);
    z[i] = zero;
  }
  for (int i = n - 1; i > 0; --i) all[i] = cnt[i] + all[i + 1];
  for (int i = 1; i < n; ++i) {
    ret = min(ret, all[i + 1] + max(0, z[i] - all[i + 1] - hv));
  }
  if (n == 1) ret = 0;
  cout << ans + ret;
  return 0;
}
