#include <bits/stdc++.h>
using namespace std;
int n, s;
int missed, cnt, ans;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> s;
  s--;
  vector<int> a(n, 0);
  int boss = 0;
  for (int i = 0, t; i < n; i++) {
    cin >> t;
    if (i == s && t != 0) {
      boss = 1;
      t = 0;
    }
    a[t]++;
  }
  if (n == 1) cout << boss, exit(0);
  boss += a[0] - 1;
  cnt = a[0];
  ans = n;
  for (int i = 1; i < n; i++) {
    cnt += a[i];
    ans = min(ans, max(missed - (a[0] - 1), n - cnt));
    if (a[i] == 0) missed++;
  }
  cout << ans + boss;
  return 0;
}
