#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 18 | 7;
int a[N], b[N], o[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, s;
  cin >> n >> s;
  --s;
  for (int i = 0; i < n; ++i) cin >> a[i], b[i] = a[i];
  for (int i = 0; i < n; ++i)
    if (!a[i]) a[i] = n;
  if (a[s]) a[s] = 0;
  priority_queue<pair<int, int> > Q;
  for (int i = 0; i < n; ++i) Q.push({a[i], i}), o[a[i]] = 1;
  for (int i = 1; i < Q.top().first; ++i) {
    if (o[i]) continue;
    auto now = Q.top();
    Q.pop();
    a[now.second] = i;
    now.first = i;
    Q.push(now);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) ans += a[i] != b[i];
  cout << ans << endl;
}
