a, b = map(int, input().split())

X = list(input().split())

X = sorted(X)
ans = 0

for i in X:
    if(b>=int(i)):
        ans += 1
        b -= int(i)
    else:
        break
if(b == 0):
    print(ans)
else:
    if(ans == 0):
        print(ans)
    else:
        print(ans - 1)