#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  m--;
  static int a[200010], u[200010];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    u[a[i]]++;
  }
  int res = 0;
  if (a[m]) {
    u[a[m]]--;
    res++;
    a[m] = 0;
    u[0]++;
  }
  sort(a, a + n);
  int mex = 0;
  while (u[mex]) mex++;
  for (int i = 1; i < n && a[i] == 0; i++) {
    res++;
    a[i] = mex;
    u[mex]++;
    while (u[mex]) mex++;
  }
  for (int i = n - 1; i > 0; i--) {
    if (a[i] > mex) {
      res++;
      a[i] = mex;
      u[mex]++;
      while (u[mex]) mex++;
    }
  }
  printf("%d", res);
}
