#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) { return a + b - max(a, b); }
long long mulmod(long long a, long long b, long long mod) {
  long long res = 0;
  a = a % mod;
  while (b > 0) {
    if (b % 2 == 1) res = (res + a) % mod;
    a = (a * 2) % mod;
    b /= 2;
  }
  return res % mod;
}
long long mod(long long a, long long b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, second;
  cin >> n >> second;
  long long arr[n + 5];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  vector<long long> vec;
  for (long long i = 0; i < n; i++) {
    if (i != second - 1) vec.push_back(arr[i]);
  }
  long long ans = 0;
  sort(vec.begin(), vec.end());
  long long last1 = 0, cur = 0, curz = 0;
  set<pair<long long, long long> > s1;
  for (auto it : vec) {
    if (it == 0)
      s1.insert(make_pair(n, cur));
    else
      s1.insert(make_pair(it, cur));
    cur++;
  }
  long long last = 0;
  set<pair<long long, long long> >::reverse_iterator it;
  set<pair<long long, long long> >::iterator it1;
  while (s1.size() > 0) {
    it = s1.rbegin();
    it1 = s1.begin();
    if ((*it1).first > last + 1) {
      ans++;
      last++;
      s1.erase(*it);
    } else {
      s1.erase(*it1);
      if ((*it1).first == last + 1) last++;
    }
  }
  if (arr[second - 1]) ans++;
  cout << ans;
}
