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
#include <stdio.h>
#include <stdlib.h>

int compare(const void* a, const void* b){
    int int_a = *((int*)a);
    int int_b = *((int*)b);
    
    if(int_a == int_b) return 0;
    else if(int_a < int_b) return 1;
    else return -1;
}

int main()
{
    int n, k;
    int results[2000];
    
    scanf("%d", &n);
    scanf("%d", &k);
    
    for(int i = 0; i < n; i++){
        scanf("%d", &results[i]);
    }
    
    qsort(results, n, sizeof(int), compare);
    
    for(int i = 0; i < n; i++){
        if(results[i] >= results[k-1]){
        }
        else{
            printf("%d", i);
            break;
        }
    }
    
    return 0;
}