#include <bits/stdc++.h>
using namespace std;
const int big = ((long long int)1 << 30);
const long long int mod = 1000000007;
int main(void) {
  int n, m, ans = 0, i, q, w, gen = 0;
  vector<int> kaz;
  vector<bool> uma;
  scanf("%d %d", &n, &m);
  m--;
  kaz.resize(n);
  uma.resize(n + 1);
  for (i = 0; i < n; i++) {
    scanf("%d", &q);
    if (i == m && q != 0) {
      ans++;
      q = 0;
    }
    if (i != m && q == 0) {
      q = n;
    }
    kaz[i] = q;
    uma[q] = 1;
  }
  sort(kaz.begin(), kaz.end());
  while (-1) {
    for (; gen <= n; gen++) {
      if (uma[gen] == 0) {
        break;
      }
    }
    if (kaz.back() <= gen) {
      break;
    }
    ans++;
    kaz.pop_back();
    uma[gen] = 1;
  }
  printf("%d\n", ans);
  return 0;
}
