#include <bits/stdc++.h>
using namespace std;
const int nmax = 200009;
int sum[nmax], nr[nmax];
int i, n, root, must, moves, lvl, w, need;
int main() {
  scanf("%d", &n);
  scanf("%d", &root);
  moves = n;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &lvl);
    if (i == root)
      if (lvl) must = 1, lvl = 0;
    nr[lvl]++;
  }
  if (n == 1) {
    moves = 0;
    cout << moves + must << '\n';
    return 0;
  }
  for (i = n - 1; 0 <= i; --i) sum[i] = sum[i + 1] + nr[i];
  for (i = 1; i <= n - 1; ++i) {
    if (nr[i] == 0) need++;
    w = nr[0] - 1 + sum[i + 1];
    moves = min(moves, max(w, need));
  }
  cout << moves + must << '\n';
  return 0;
}
