#include #include using namespace std; using namespace atcoder; #define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using ll = long long; #define pint pair #define pll pair const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; using mint = modint1000000007; int main() { int n, k; cin >> n >> k; int p[n]; rep(i, n) cin >> p[i]; sort(p, p + n, greater()); while (k > 0 && p[k - 1] == p[k]) { k--; } cout << k << endl; return 0; }