#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int freq[N];
int A[N];
int prefix[N];
int main() {
  int n, s, ans = INT_MAX - 5, max_val = 0;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    if (i != s) {
      freq[A[i]]++;
      max_val = max(max_val, A[i]);
    }
  }
  if (n == 1) {
    if (A[1] != 0)
      cout << 1 << endl;
    else
      cout << 0 << endl;
    return 0;
  }
  int current = freq[0];
  prefix[0] = 0;
  for (int i = 1; i <= max_val; i++) {
    prefix[i] = prefix[i - 1];
    if (freq[i] == 0) prefix[i]++;
  }
  for (int i = max_val; i >= 0; i--) {
    ans = min(ans, max(prefix[i], current));
    current += freq[i];
  }
  if (A[s] != 0) ans++;
  cout << ans << endl;
  return 0;
}
