#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n, m;
  while (scanf("%d %d", &n, &m) != EOF) {
    int i, j, num = 0;
    memset(a, 0, sizeof(a));
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == 0) num++;
    }
    int sum = 0;
    if (a[m - 1] != 0) {
      sum++;
      num++;
      a[m - 1] = 0;
    }
    sort(a, a + n);
    int z = num, t = a[num - 1], k = n - 1;
    for (i = num; i < n; i++) {
      while ((a[i] - t) > 1) {
        if (z > 1) {
          z--;
          t++;
          sum++;
        } else {
          a[k] = -1;
          k--;
          t++;
          sum++;
        }
        if (a[i] == -1) break;
      }
      if (a[i] == -1) break;
      t = a[i];
    }
    if (z > 1) sum = sum + z - 1;
    printf("%d\n", sum);
  }
}
