#ifdef __LOCAL #define _GLIBCXX_DEBUG #endif #include #include #include #include #include #include using namespace std; typedef long long LL; #define REP(i,n) for(int i=0;i<(n);++i) #define REPREV(i,n) for(int i=(n-1);i>=(0);--i) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define ALL(x) x.begin(),x.end() #define BIT(x,i)(((x)>>(i))&1) template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a inline void out(T a){cout << a << endl;} template int larger_equal(vector& vec, T val){ auto ptr = lower_bound(ALL(vec), val); if(ptr == vec.end()){ return -1; } int idx = ptr - vec.begin(); return idx; } template int larger_than(vector& vec, T val){ auto ptr = upper_bound(ALL(vec), val); if(ptr == vec.end()){ return -1; } int idx = ptr - vec.begin(); return idx; } template int lower_equal(vector& vec, T val){ auto ptr = upper_bound(ALL(vec), val); int idx = ptr - vec.begin() - 1; return idx; } template int lower_than(vector& vec, T val){ auto ptr = lower_bound(ALL(vec), val); int idx = ptr - vec.begin() - 1; return idx; } template inline void out_vector(vector& vec){ REP(i, vec.size()){cout << vec[i] << " ";} cout << endl; } template struct Matrix { vector> _array; int _Nr; int _Nc; Matrix(int Nr, int Nc): _Nr(Nr), _Nc(Nc) { _array = vector(Nr, vector(Nc)); }; void to_eye(){ REP(i, _Nr){ REP(j, _Nc){ if(i == j){ _array[i][j] = T(1); }else{ _array[i][j] = T(0); } } } } vector& operator[] (int i){ return _array[i]; } Matrix operator* (Matrix& other){ if(_Nc != other._Nr){ throw runtime_error("Cannot multiply two matrix"); } Matrix res(_Nr, other._Nc); REP(i, _Nr){ REP(j, other._Nc){ T val = T(0); REP(k, _Nc){ val += _array[i][k] * other._array[k][j]; } res[i][j] = val; } } return res; } void show(){ REP(i, _Nr){ REP(j, _Nc){ cout << _array[i][j] << " "; } cout << endl; } } }; template T calcPow(T& val, LL n, T& init_val){ T ans = init_val; while(n > 0){ if((n & 1) == 1){ ans = val * ans; } val = val * val; n = (n >> 1); } return ans; }; struct Edge { int to; LL w; Edge(int to, LL w): to(to), w(w) {} }; string str_slice(int i, int j, string& S){ int n = j - i; return S.substr(i, n); } using Graph = vector>; const LL INF = 1LL << 60; const int inf = INT_MAX / 2; int main(){ int N, K; cin >> N >> K; vector A(N); REP(i, N){ cin >> A[i]; } map counts; REP(i, N){ counts[A[i]] += 1; } priority_queue que; for(auto p: counts){ que.push(p.second); } int ans = 0; while(K > 0){ auto v = que.top(); que.pop(); K -= v; ++ans; } out(ans); return 0; }