#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, s = 0, ans = 0;
  cin >> n >> s;
  --s;
  vector<int> a(n), b(n), o(n), f(n);
  vector<vector<int>> bin(n + 1);
  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;
  for (int i = 0; i < n; ++i) bin[a[i]].push_back(i), o[a[i]] = 1;
  int r = n;
  while (bin[r].empty()) --r;
  for (int i = 1; i < r; ++i) {
    if (o[i]) continue;
    int now = bin[r].back();
    bin[r].pop_back();
    a[now] = i;
    while (bin[r].empty()) --r;
  }
  for (int i = 0; i < n; ++i) ans += a[i] != b[i];
  cout << ans << endl;
}
