n, x = map(int, input().split())

nums = sorted(list(map(int, input().split())))

count = 0
for i, num in enumerate(nums):
    if num <= x:
        if i != nums.index(num):
            count += 1
            x -= num
        else:
            if num == x:
                count += 1
                x -= num
    else:
        break

print(count)