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