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