1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <map>

using namespace std;

int main()
{
    map <int, int> M;
    int n, k, a, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin>>a;
        M[a]++;
    }
    for (map<int,int>::reverse_iterator it = M.rbegin(); it != M.rend(); it++ )
    {
        ans+=it->second;
        if (ans >= k)
            break;
    }
    cout <<ans;
    return 0;
}