import sys

N, x = sys.stdin.readline().split()
N = int(N)
x = int(x)
al = [int(a) for a in sys.stdin.readline().split()]

al.sort()

used = 0
ans = N
for i, a in enumerate(al):
    if used+a > x:
        ans = i
        break
    used += a

print(ans)
    
        
        
