from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,x = inpl()
a = inpl()
a.sort()
if a[0] > x:
    print(0)
elif sum(a) == x:
    print(n)
elif sum(a) > x:
    print(n-1)
else:
    s = 0
    for i,y in enumerate(a):
        if s + y <= x:
            s += y
        else:
            print(i)
            break
    else:
        print(n-1)