hito, ame = map(int, input().split())
NeedAme = list(map(int, input().split()))
NeedAme.sort()

ans = 0
total = 0
for n in NeedAme:
    if total + n <= ame:
        ans += 1
        total += n
    else:
        break

print(ans)
