import math
import sys

n, x = map(int, input().split())
a = [int(val) for val in input().split()]

sort = sorted(a)
ans = 0
for i in range(n - 1):
    x -= sort[i]
    if x >= 0:
        ans += 1

if x == a[n-1]:
    ans += 1


print(ans)
