# -*-coding : utf-8 -*-
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
tmp = []

for i in range(0, N):
    tmp.append(min(a))
    a.remove(tmp[i])

for i in range(0, N):
    if x >= tmp[i]:
        x -= tmp[i]
        ans += 1

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

print(ans)