N, M = map(int, input().split())
C = sorted(list(map(int, input().split())))

ans = 0
for c in C:
    M = M - c
    if M >= 0:
        ans += 1
print(ans)