N, X = map(int, input().split())
lists = list(map(int, input().split()))

count = 0
for num in sorted(lists):
    X -= num
    if X == 0 and num == lists[-1]:
        print(count + 1)
        exit()
    if X >= 0 and num != lists[-1]:
        if num == lists[-1] and X > 0:
            break
        count += 1
        continue
    break
print(count)