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

a = sorted(a)

ans = 0
temp = x

while ans < n:
    temp -= a[ans]
    ans += 1
    if temp == 0:
        break
    elif temp < 0:
        ans -= 1
        break

print(ans)
