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