l,w[10001],i;main(j){for(scanf("%*d%d",&l);~scanf("%d",w+i++););for(;--i;)for(j=0;++jw[j])w[j-1]^=w[j]^=w[j-1]^=w[j];for(i=*w;i<=l&&w[j-1];i+=w[j++]);i=!printf("%d",j-1);}