N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(N):
    if a[i] <= x:
        x -= a[i]
        if a[i] != a[-1] and 0 < x:
            count += 1
        elif a[i] == a[-1] and 0 == x:
            count += 1
print(count)
