#include <bits/stdc++.h>
using namespace std;
const int MAX = 200200;
int unit[MAX], cnt[MAX];
int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  bool flag = false;
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &x);
    if (s == i + 1 && x) {
      flag = true;
      x = 0;
    }
    ++cnt[x];
    unit[x] |= 1;
  }
  for (int i = 1; i <= n; ++i) cnt[i] += cnt[i - 1], unit[i] += unit[i - 1];
  int ans = n;
  for (int i = 0; i < n; ++i) {
    int missing = i + 1 - unit[i];
    int to_be_replaced = cnt[n] - cnt[i] + cnt[0] - 1;
    ans = min(ans, max(missing, to_be_replaced));
  }
  printf("%d\n", ans + flag);
  return 0;
}
