#!/bin/awk -f

function qsort(A, l, r,  mid, il, ir, i)
{
    if(!l)l = 1;
    if(!r){for(i in A){r++;}r++;}
    if(r-l == 2){
        if(sort_cmp(A[l+1], A[l])){
            t = A[l]; A[l] = A[l+1]; A[l+1] = t;
        }
        return;
    }else if(r-l < 2)return;
    mid = int((l+r)/2);
    if(sort_cmp(A[mid], A[l])){
        t = A[mid]; A[mid] = A[l]; A[l] = t;
    }
    if(sort_cmp(A[r-1], A[mid])){
        t = A[r-1]; A[r-1] = A[mid]; A[mid] = t;
        if(sort_cmp(A[mid], A[l])){
            t = A[mid]; A[mid] = A[l]; A[l] = t;
        }
    }
    il = l;  ir = r-1;
    while(il <= ir){
        while(sort_cmp(A[il], A[mid]))il++;
        while(sort_cmp(A[mid], A[ir]))ir--;
        if(il < ir){
            t = A[il]; A[il] = A[ir]; A[ir] = t;
            if(mid == il)mid = ir;
            else if(mid == ir)mid = il;
            il++; ir--;
        }else if(il == ir){
            il++; ir--;
        }
    }
    qsort(A, l, il);
    qsort(A, il, r);
}
function sort_cmp(a, b)#bool(a<b)
{
    return a<b;
}

NR==1{N=$1; X=$2}
NR==2{split($0,A)}
END{
    qsort(A)
    sum = 0;
    if(X<A[1]){print 0;exit}
    for(i=1;i<=N;i++){
        sum += A[i];
        if(sum>=X){
            print i;
            exit;
        }
    }
    print N-1;
}
