N, X = map(int, input().split())
lists = list(map(int, input().split()))
 
if X - sum(lists) > 0:
    print(len(lists) - 1)
    exit()
 
count = 0
for num in sorted(lists):
    X -= num
    if X >= 0:
        count += 1
        if num == lists[-1]:
            break
        continue
    break
print(count)