#include <bits/stdc++.h>
using namespace std;
long long A[300001], B[300001], cnt[300001], cntb[300001];
int main() {
  memset(cnt, 0, sizeof cnt);
  ;
  memset(cntb, 0, sizeof cntb);
  ;
  long long n, s, ans = 0, c = 0;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 1; i <= n; i++) {
    if (i == s) {
      if (A[i]) {
        A[i] = 0;
        ans++;
      }
      continue;
    }
    if (A[i] == 0) {
      c++;
      continue;
    } else
      cnt[A[i]]++;
  }
  ans += c;
  long long j = n - 1;
  while (cnt[j] == 0 && j > 0) {
    j--;
  }
  for (int i = j; i >= 1; i--) {
    cntb[i] = cntb[i + 1];
    cntb[i] += cnt[i];
  }
  long long cc = 0;
  for (int i = 1; i <= j; i++) {
    if (cntb[i] <= cc) break;
    if (cnt[i] == 0) {
      if (c)
        c--;
      else
        cc++, ans++;
    }
  }
  cout << ans << endl;
}
