import sys

input = sys.stdin.readline


def ii():
    return int(input())


def il():
    return list(map(int, input().split()))


N, X = il()
A = sorted(il())
c = 0
for i in range(N + 1):
    if sum(A[:i]) <= X:
        c = i
print(c)
