#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
int main() {
  long long int n, s, x, i, j;
  while (cin >> n >> s) {
    long long int fr[n + 5], a[n + 5];
    memset(fr, 0, sizeof(fr));
    long long int z = 0;
    for (long long int i = 1; i < n + 1; i++) {
      scanf("%lld", &a[i]);
      if (a[i] > 0 && s != i)
        fr[a[i]]++;
      else if (a[i] == 0)
        z++;
    }
    if (n == 1) {
      if (z == 1) cout << "0" << endl;
      continue;
    }
    for (i = 2; i <= n; i++) fr[i] += fr[i - 1];
    long long int min1 = 999999999999;
    long long int cn = 0;
    if (a[s] == 0) z--;
    for (i = 1; i < n; i++) {
      if (fr[i] == fr[i - 1]) cn++;
      long long int r = fr[n] - fr[i] + z;
      long long int r1 = 0;
      if (a[s] != 0) r1++;
      min1 = min(min1, max(cn, r) + r1);
    }
    cout << min1 << endl;
  }
  return 0;
}
