#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, INF = 1e9;
int d[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ans = 0, cur = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &d[i]);
    if (d[i] == 0 && i != m) d[i] = INF;
    if (i == m && d[i] != 0) {
      ans++;
      d[i] = 0;
    }
  }
  sort(d + 1, d + 1 + n);
  int i = 1;
  while (i <= n) {
    while (i <= n && d[i] < cur) ++i;
    if (i <= n && d[i] != cur) {
      n--;
      ans++;
    }
    cur++;
  }
  printf("%d\n", ans);
}
