#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:32000000")
using namespace std;
inline bool read(int& val) { return scanf("%d", &val) != -1; }
inline bool read(long long& val) { return scanf("%I64d", &val) != -1; }
inline bool read(double& val) { return scanf("%lf", &val) != -1; }
inline bool read(char* val) { return scanf("%s", val) != -1; }
template <class T1, class T2>
inline bool read(T1& a, T2& b) {
  return read(a) && read(b);
}
template <class T1, class T2, class T3>
inline bool read(T1& a, T2& b, T3& c) {
  return read(a) && read(b) && read(c);
}
template <class T1, class T2, class T3, class T4>
inline bool read(T1& a, T2& b, T3& c, T4& d) {
  return read(a) && read(b) && read(c) && read(d);
}
template <class T1, class T2, class T3, class T4, class T5>
inline bool read(T1& a, T2& b, T3& c, T4& d, T5& e) {
  return read(a) && read(b) && read(c) && read(d) && read(e);
}
const int N = 1111111;
int cnt[N];
int main() {
  int n, s;
  read(n, s);
  int ans = 0;
  for (int i = 0, _ = (n); i < _; ++i) {
    int val;
    read(val);
    if (i + 1 == s) {
      if (val != 0) {
        val = 0;
        ans++;
      }
    } else {
      if (val == 0) {
        val = n;
      }
    }
    cnt[val]++;
  }
  int i = 0;
  int j = n;
  while (cnt[j] == 0) j--;
  while (i < j && cnt[i] != 0) i++;
  while (i < j) {
    ans++;
    cnt[i]++;
    cnt[j]--;
    while (cnt[j] == 0) j--;
    while (i < j && cnt[i] != 0) i++;
  }
  printf("%d\n", ans);
  return 0;
}
