1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;

  int l;
  int k;
  int minn;
  
int main() {
  cin >> l >> k;
  int tab[l];
  
  for(int i = 0; i < l; i++)
    cin >> tab[i];
  sort(tab, tab + l);
  reverse(tab, tab+l);
  int i = -1;
  while((minn < k || tab[i] == tab[i+1] ) && i < l-1){
    minn++;
    i++;
  }
  
  cout << minn;
}