# -*-coding : utf-8 -*-
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
tmp = []

for i in range(0, N):
    tmp = min(a)
    if x >= min(a):
        x -= tmp
        a.remove(tmp)
        ans += 1
    else :
        break

if x != 0 and ans > 0:
    ans -= 1

print(ans)