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())
if sum(A) == N:
    print(N)
    exit()
c = 0
for i in range(N):
    if sum(A[:i]) <= X:
        c = i
print(c if c != N else N - 1)
