n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
if sum(a) < x:
    print(n-1)
    exit()
if sum(a) == x:
    print(n)
    exit()
idx = s = 0
while True:
    s += a[idx]
    if x == s:
        print(idx+1)
        exit()
    if x < s:
        print(max(0, idx-2))
        exit()