#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], cnt[N], dp[N];
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  vector<int> arr;
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (i == m)
      if (x) x = 0, flag = 1;
    a[x]++;
  }
  if (n == 1) {
    printf("%d", flag);
    return 0;
  }
  int cnt = 1, m = 0, Min = 1e9;
  for (int i = 1; i <= n; i++) {
    cnt += a[i];
    if (a[i] == 0) m++;
    if (cnt + m >= n) {
      int d = n - cnt;
      if (a[0] - 1 > m)
        printf("%d", a[0] - 1 + flag);
      else
        printf("%d", m + flag);
      return 0;
    }
  }
  return 0;
}
