#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e10;
int main() {
  ios_base::sync_with_stdio(0);
  int n, s;
  cin >> n >> s;
  --s;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    if (i != s) ++b[a[i]];
  }
  vector<int> suff(n + 1);
  suff[n] = 0;
  for (int i = n - 1; i >= 0; --i) suff[i] = suff[i + 1] + b[i];
  int ans = n - 1;
  int cur = 0;
  for (int i = 1; i < n; ++i) {
    if (!b[i]) ++cur;
    ans = min(ans, max(cur, suff[i + 1] + b[0]));
  }
  if (a[s] != 0) ++ans;
  cout << ans << endl;
  return 0;
}
