#include <bits/stdc++.h>
using namespace std;
const int MN = 200 * 1000 + 200;
set<int> s;
multiset<int, greater<int> > s2;
int cnt[MN];
int a[MN];
int main() {
  ios::sync_with_stdio(0);
  int n, s1;
  cin >> n >> s1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0 && i != s1 - 1) {
      a[i] = n;
    }
    if (i == s1 - 1 && a[i] != 0) {
      a[i] = 0;
      ans++;
    }
    s2.insert(a[i]);
    cnt[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (!cnt[i]) s.insert(i);
  }
  while (!s.empty() && !s2.empty()) {
    int t = *s2.begin();
    int t2 = *s.begin();
    if (t <= t2) break;
    ans++;
    cnt[t]--;
    cnt[t2]++;
    s.erase(s.begin());
    s2.erase(s2.begin());
  }
  cout << ans;
}
