def resolve():
    n,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.sort()
    num=0
    cnt=0
    if x<l[0]:
        cnt=0
        print(cnt)
    else:
        for i in range(n-1):
            if num<x:
                num+=l[i]
                cnt+=1
        if x-num==l[n-1]:
            cnt+=1
        print(cnt)
resolve()
