n, x = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0
i = 0
while True:
    x -= a.pop()
    ans += 1
    i += 1
    if x == 0:
        break
    elif len(a) == 0 or i == n:
        ans -= 1
        break
print(ans)
