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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <algorithm>

using namespace std;

int tab[2007];
int ile[2007];
int n, k, x;

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	int j = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> x; 
		x *= -1;
		if (ile[-x] == 0)
		{
			tab[j] = x;
			j++;
		}
		ile[-x]++;
	}
	sort(tab, tab + 2007);
	/*
		5 3
		75 90 120 75 40

		5 2 
		1 1 1 2 3

		5 1 
		3 3 3 2 1

		5 3
		1 1 1 1 1

		5 3
		1 1 1 1 2
	for (int i = 0; i < j; i++)
		cout << tab[i] << " ";
	cout << endl;
	for (int i = 0; i < j; i++)
		cout << ile[-tab[i]] << " ";
	cout << endl;
	*/

	int wyn = 0;
	for (int i = 0; i < j; i++)
	{
		//cout << tab[i] << " " << ile[tab[i]] << endl;
		wyn += ile[-tab[i]]; 
		if (wyn >= k)
		{
			cout << wyn << endl;
			return 0;
		}
	}

	

	return 0;
}