# https://atcoder.jp/contests/agc027/tasks/agc027_a
n, x = map(int, input().split())
nums = [int(i) for i in input().split()]
nums.sort()

if sum(nums) == x:
    print(n)
else:
    c = 0
    for i in range(n):
        if x >= nums[i]:
            c += 1
            x -= nums[i]
    if x > 0:
        print(max(0, c - 1))
    else:
        print(c)