1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int u, t, g = 0, p = t;
  scanf("%i %i", &u, &t);
  vector<int> arr(u);
  for (int i = 0; i < u; i++) scanf("%d", &arr[i]);
  sort(arr.begin(), arr.end());
  while (t >= 0)
  {
    u--; g++; t--;
    if (arr[u] == arr[u - 1] && g <= p) t++;
  }
  cout << g;
};