n,x = map(int,input().split())

s = list(map(int,input().split()))

ans = 0

s.sort()

if sum(s)==x:
    print(n)
elif sum(s)<x:
    print(n-1)
else:
    if s[0]>x:
        print(0)
    else:
        while x>0:
            ans += 1
            x -= s[0]
            del s[0]
        print(ans)
        
    