import sys

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

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

a.sort()

cnt_children = 0
for i in range(n):
    if x >= a[i]:
        cnt_children += 1
        x -= a[i]

if x > 0 and cnt_children != 0:
    cnt_children -= 1

print("{}".format(cnt_children))