#include #define N 1000001 #define F(i,n) for(int i = 0;i < n;i++) void z(const int a[],int b[],int n){static int c[N] = {0};int ct = 0;for(int i = 0;i < n;i++){c[a[i]]++;}for(int i = 0;i < N;i++){if(c[i] != 0){for(int i2 = 0;i2 < c[i];i2++){b[ct] = i;ct++;}}}} int main(void){ int n,m,t=0; scanf("%d%d",&n,&m); int c[n]; F(i,n)scanf("%d",&c[i]); z(c,c,n); while(m!=0){ for(;;){ if(c[t]<=0)t++;else break; } c[t]--;m--; } t=0; F(i,n){ if(c[i]==0)t++; } printf("%d\n",t); return 0; }