#include <bits/stdc++.h>
using namespace std;
int N, S, A[200005];
int cnt[200005];
int psm[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> S;
  int C = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    if (i == S && A[i])
      C = 1;
    else
      cnt[A[i]]++;
  }
  if (N == 1) {
    cout << (A[1] == 0 ? 0 : 1) << '\n';
    return 0;
  }
  for (int i = N - 1; i >= 0; i--) psm[i] = psm[i + 1] + cnt[i];
  int mn = 1e9;
  int L = 0;
  if (C) cnt[0]++;
  for (int i = 1; i <= N - 1; i++) {
    L += cnt[i] == 0;
    int P = psm[i + 1];
    if (cnt[0] > 1) P += cnt[0] - 1;
    int Ci = P + C;
    if (L > P) Ci += (L - P);
    mn = min(Ci, mn);
  }
  cout << mn << '\n';
  return 0;
}
