#include <bits/stdc++.h>
using namespace std;
void rf() {}
const int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};
const int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};
const int Nx[4] = {0, 0, -1, 1};
const int Ny[4] = {1, -1, 0, 0};
const long long LINF = (long long)5e18;
const int INF = 1e9 + 7;
const int N = 6e5 + 1;
const int MAXN = 1e6 + 50;
const double EPS = 1e-9, PI = 3.14159265359;
inline int get_int() {
  char x = getchar();
  int ret = 0;
  bool neg = 0;
  while (!('0' <= x && x <= '9')) {
    if (x == '-') neg = 1;
    x = getchar();
  }
  while ('0' <= x && x <= '9') {
    ret = ret * 10 + x - '0';
    x = getchar();
  }
  if (neg) ret *= -1;
  return ret;
}
int n, second;
int a[N];
multiset<int> st;
int main() {
  srand(time(0));
  rf();
  cin >> n >> second;
  int shit = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (second == i)
      ans += (a[second] > 0);
    else {
      if (a[i] == 0) {
        shit++, ans++;
      } else {
        st.insert(a[i]);
      }
    }
  }
  int lvl = 0;
  while (!st.empty()) {
    int fr = *st.begin();
    if (fr <= lvl) {
      st.erase(st.begin());
    } else if (fr == lvl + 1) {
      ++lvl;
      st.erase(st.begin());
    } else {
      ++lvl;
      if (shit > 0) {
        shit--;
      } else {
        ans++;
        st.erase(--st.end());
      }
    }
  }
  cout << ans;
  return 0;
}
