#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int d[maxn], mark[maxn], root, ans, mx, mex, n;
void move(int x) {
  --mark[x];
  ++mark[mex];
  ++ans;
  while (mark[mex]) ++mex;
  while (!mark[mx]) --mx;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> root;
  for (int i = 1; i <= n; i++) cin >> d[i], ++mark[d[i]];
  if (d[root]) --mark[d[root]], d[root] = 0, ++mark[0], ++ans;
  while (mark[mex]) ++mex;
  while (mark[0] > 1) move(0);
  for (int i = 1; i <= n; i++) mx = max(mx, d[i]);
  while (mx > mex) move(mx);
  cout << ans;
  return 0;
}
