from itertools import accumulate n, m = map(int, input().split()) print(len([i for i in accumulate(sorted(map(int, input().split()))) if i <= m]))