#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, s;
  cin >> n >> s;
  s--;
  vector<int> A(n), cnt(n);
  int res = 0, amo = 0;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    if (A[i] == 0 && i != s) {
      amo++;
    }
    if (A[i] != 0 && i == s) {
      res++;
      A[i] = 0;
    }
    cnt[A[i]]++;
  }
  vector<int> pref(n);
  for (int i = 1; i < n; i++) {
    pref[i] = pref[i - 1];
    if (cnt[i] == 0) {
      pref[i]++;
    }
  }
  int best = INT_MAX;
  for (int i = n - 1; i >= 1; i--) {
    best = min(best, max(pref[i], amo));
    amo += cnt[i];
  }
  cout << res + (n == 1 ? 0 : best) << '\n';
  return 0;
}
