#include using namespace std; int main(){ int N, K; cin >> N >> K; vector p(N); for (int i = 0; i < N; i++){ cin >> p[i]; } sort(p.begin(), p.end(), greater()); if (p[K - 1] == p[0]){ cout << 0 << endl; } else if (K == N){ cout << N << endl; } else { int ans = K; while (p[ans - 1] == p[ans]){ ans--; } cout << ans << endl; } }