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

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

count = 0
for num in nums:
    if (num <= x and num != nums[-1]) or (num == x and num == nums[-1]):
        count += 1
        x -= num        
    else:
        break

print(count)