#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 123;
const int mod = 1e9 + 7;
const int inf = 1e9;
int n, a[N], cnt[N], second;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> second;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (i != second) cnt[a[i]]++;
  }
  if (n == 1) {
    cout << (a[second] > 0) << endl;
    return 0;
  }
  int ans = mod;
  int all = n - 1;
  int now = 0;
  for (int i = 1; i <= n; i++) {
    if (!cnt[i]) now++;
    all -= cnt[i];
    ans = min(ans, max(now, all));
  }
  if (a[second]) ans++;
  cout << ans << endl;
  return 0;
}
