#include #define N 1000000 #define F(i,n) for(int i = 0;i < n;i++) void z(int a[],int n,int min,int max){int s = a[(min+max)/2];int min2=min; int max2=max;int tmp;for(;;){for(;;){if(a[min2]>=s)break;min2++;}for(;;){if(a[max2]<=s)break;max2--;}if(min2>=max2)break;tmp=a[min2];a[min2]=a[max2];a[max2]=tmp;min2++;max2--;}if(minmax2+1) z(a,n,max2+1,max);} 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,n,0,n-1); 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; }