#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int sm[N], cnt[N];
int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  int onePlus = 0;
  for (int i = 1; i < n + 1; i++) {
    int x;
    scanf("%d", &x);
    if (i == s) {
      if (x) onePlus = 1;
    } else {
      cnt[x]++;
    }
  }
  if (n == 1) {
    printf("%d\n", onePlus);
    return 0;
  }
  sm[0] = cnt[0];
  for (int i = 1; i < n + 1; i++) sm[i] = sm[i - 1] + cnt[i];
  int missing = 0;
  int ans = n;
  for (int i = 1; i < n; i++) {
    if (!cnt[i]) missing++;
    int bad = n - 1 - (sm[i] - sm[0]);
    ans = min(ans, max(missing, bad) + onePlus);
  }
  printf("%d\n", ans);
  return 0;
}
