import numpy as np

N, x = list(map(int, input().split()))
a = np.asarray(list(map(int, input().split())))
a = np.sort(a)
s = 0
for i in range(1, N):
    if np.sum(a[:i]) < x:
        s += 1
if np.sum(a) == x:
    s += 1
print(s)