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
#include <iostream>
#include <cstdlib>

using namespace std;

typedef short ElementT;

int sortuj( const ElementT * arg1, const ElementT * arg2 )
{
    if( * arg1 >* arg2 )
         return - 1;
   
    if( * arg1 <* arg2 )
         return 1;
   
    return 0;
}

int main()
{
    int n, k, i = 0, ret;
    ElementT a[2000];
    cin >> n >> k;
    while (i < n) cin >> a[i++];
 //   cout << a[0] << ' ' << a[1] << endl;

    qsort( a, n, sizeof(ElementT),( int( * )( const void *, const void * ) ) sortuj );

    while (k <= n && a[k - 1] == a[k]) k++;
//    cout << a[0] << ' ' << a[1] << endl;
    cout << k;
    return 0;
}