#include <stdio.h>
int main()
{
    int N,tmp,x,k,sum=0;
    int a[100];
    int i=0,j=0;


    scanf("%d %d",&N,&x);

    if(N < 2 || x < 1 || x > 1000000000){
        break;
    }

    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }

    k = N;

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(a[j]>a[j+1]){
                tmp = a[j+1];
                a[j+1] = a[j];
                a[j] = tmp;
            }
        }
    }

    for(i=0;i<N;i++){
        sum = sum + a[i];
    }

    while(sum > x){
        sum = sum - a[N-1];
        N--;
        k--;
    }

    if(sum != x){
        k--;
    }

    if(k<0){
        k = 0;
    }
    printf("%d",k);
    return 0;
}