#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int a[maxn];
set<pair<int, int> > q;
int main() {
  int n, s;
  while (scanf("%d%d", &n, &s) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int ans = 0;
    if (a[s] > 0) {
      a[s] = 0;
      ans++;
    }
    q.clear();
    for (int i = 1; i <= n; i++) {
      if (i == s) continue;
      if (a[i] == 0)
        q.insert(make_pair(n, i));
      else
        q.insert(make_pair(a[i], i));
    }
    int i = 1, fg = 0;
    while (i < n) {
      if (q.size() == 0) break;
      int num, id;
      pair<int, int> p;
      p = *(q.begin());
      num = p.first;
      id = p.second;
      if (num < i)
        q.erase(p);
      else if (num == i) {
        fg = 1;
        q.erase(p);
      } else if (num > i && fg) {
        fg = 0;
        i++;
      } else if (num > i && !fg) {
        ans++;
        p = *(q.rbegin());
        num = p.first;
        id = p.second;
        q.erase(p);
        q.insert(make_pair(i, id));
        i++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
