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
#include <iostream>
#include <algorithm>
using namespace std;

int n, k, a[2001], licz, j;

int main()
{
    cin>>n>>k;
    
    for(int i = 1; i<=n; i++)
    {
        cin>>a[i];
    }
    
    sort(a+1, a+n+1);
    
    licz = k;
    
    while(n-licz > 0 && a[n-licz] == a[n-licz+1])
    {
        licz++;
    }
    
    cout<<licz;
    return 0;
}