#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int a[300000];
int s[300000];
int main() {
  int i, j, k, l;
  cin >> n >> m;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  m--;
  int ans = 0;
  if (a[m] != 0) ans = 1, a[m] = 0;
  if (n == 1) return !printf("%d", ans);
  for (i = 0; i < n; i++) s[a[i]]++;
  int z = 0;
  int now = 0;
  int mi = 0x3f3f3f3f;
  for (i = 1; i < n; i++) {
    if (s[i] == 0) z++;
    now += s[i];
    mi = min(mi, max(n - 1 - now, z));
  }
  cout << ans + mi;
  return 0;
}
