1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include<iostream>
#include<algorithm>
using namespace std;
int t[2007];
int main(){
  int n, k;
  cin >> n >> k;
  for(int i = 0;i < n;i++){
    cin >> t[i];
  }
  sort(t, t + n);
  int i = n - k - 1;
  while(i >= 0 && t[i] == t[i + 1]){
    k++;
    i--;
  }
  cout << k;
}