#include <bits/stdc++.h>
using namespace std;
int n, a[200002], s, cnt[200002], cnt0, res;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  scanf("%d%d", &n, &s);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (i == s && a[i] != 0) {
      a[i] = 0;
      res++;
    } else {
      if (a[i] == 0) cnt0++;
    }
    cnt[a[i]]++;
  }
  int p = 0;
  for (int i = 1; i <= n; ++i) {
    if (i != s && a[i] == 0) {
      while (cnt[p]) p++;
      res++;
      cnt[p]++;
      a[i] = p;
    }
  }
  sort(a + 1, a + 1 + n);
  for (int i = n; i >= 1; --i) {
    while (cnt[p]) p++;
    if (p >= a[i]) break;
    res++;
    cnt[p]++;
  }
  printf("%d", res);
  return 0;
}
