i,j,w[];c(int*a,int*b){return*a-*b;}main(){for(;~scanf("%d",w+i++););for(qsort(w+2,w[1],4,c);w[0]--;j+=!--w[j+2]);j=!printf("%d",j);}