1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,k;
vector <int> v;
int main(){
	scanf("%d%d",&n,&k);
	for (int i =0; i < n; i++){
		int x;
		scanf("%d", &x);
		v.push_back(x);
	}


	v.push_back(0);
	sort(v.begin(), v.end());

	int score = 0;
	for (int i = n; i > 0; i--){
		score++;
		if (score >= k && v[i] != v[i-1]){
			printf("%d\n", score);
			return 0;
		}
	}
	
	if ( k >= n ){
		printf("%d\n", n);
		return 0;
	}
	printf("%d\n", score);


}