import sys

input = sys.stdin.readline
n, x = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
cnt = 0
for a in a_list:
    if x >= a:
        cnt += 1
        x -= a
if x > 0:
    cnt -= 1
print(max(cnt, 0))
