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