n,x = map(int,input().split())
a = list(map(int,input().split()))
res = int()
a.sort()

for i in range(n):
    if i == n-1:
        if a[i] == x:
            res += 1
        else:
            break
    elif a[i] < x:
        x -= a[i]
        res += 1
    else:
        break

print(res)
