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