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
#include <iostream>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int n,k;
	int t[3000];
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;i++){
		scanf("%d", &t[i]);
	}
sort(t, t + n,greater<int>());

int ile=k;// 7 7 6 6 4
for(int i=k;i<n;i++){
	if(t[i]==t[i-1]){
		ile++;
	}else{
	
	
		break;
	}
}

		printf("%d\n", ile);
	
  
	return 0;
}