#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long LINF = 2e18;
void inv(bool e);
bool brute, alter;
int cnt_tests = 1;
const int N = 3e5;
int n, m;
vector<int> arr;
void inp() {
  cin >> n >> m;
  arr.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
}
int cnt[N];
void solve() {
  int ans = 0, mx = -1;
  multiset<int> sorted;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0 && i + 1 != m) {
      arr[i] = n + 10;
    }
    if (arr[i] != 0 && i + 1 == m) {
      arr[i] = 0;
      ans++;
    }
    cnt[arr[i]]++;
    sorted.insert(arr[i]);
  }
  for (int i = 1; i < N; i++) {
    mx = *sorted.rbegin();
    if (mx <= i) break;
    if (cnt[i] == 0) {
      cnt[mx]--;
      cnt[i]++;
      ans++;
      sorted.erase(sorted.find(mx));
    }
  }
  cout << ans;
}
void stress() {}
void naive() {}
void run();
int main() {
  if (0) {
    freopen("stack.in", "r", stdin);
    freopen("stack.out", "w", stdout);
  }
  brute = false;
  for (int i = 0; (i < cnt_tests); i++) {
    run();
  }
  cerr << '\n' << "Time: " << clock() / 1000.0 << " ms";
  return 0;
}
void run() {
  if (!brute) {
    inp();
  } else {
    stress();
  }
  solve();
}
void inv(bool e) {
  if (!e) {
    vector<int> a;
    a[-1] += 1;
  }
}
