#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], b[N], sum[N];
int main() {
  int n, s;
  while (scanf("%d%d", &n, &s) == 2) {
    memset(b, 0, sizeof b);
    memset(sum, 0, sizeof sum);
    int ans = n, flag = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
      if (i == s) {
        if (a[i] != 0) {
          flag = 1;
          a[i] = 0;
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      b[a[i]]++;
    }
    int cnt = b[0] - 1;
    b[0] = 1;
    for (int i = 1; i < n; i++) {
      sum[i] = sum[i - 1] + (b[i] == 0);
    }
    for (int i = n - 1; i >= 0; i--) {
      if (cnt >= sum[i]) {
        ans = min(ans, cnt + flag);
      }
      while (b[i]) {
        b[i]--, cnt++;
        if (cnt >= sum[i]) {
          ans = min(ans, cnt + flag);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
