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