n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
give = a[::]

for i in range(n):
    if i == n-1:
        give[i] = x
    else:
        give[i] = min(x, a[i])
        x -= give[i]

print sum([give[i] == a[i] for i in range(n)])
    