# -*- coding: utf-8 -*-
from sys import stdin

in_strings = lambda: stdin.readline()[:-1] # s = in_strings()
in_int = lambda: int(stdin.readline()) # N = in_int()
in_intlist = lambda: list(map(int, stdin.readline().split())) # List = in_intlist()

N, X = in_intlist()
a_list = in_intlist()

a_list.sort()
print(a_list)

flag = 1
dist = 0
count = 0
for i in range(N):
    dist += a_list[i]
    if dist <= X:
        count += 1
    else:
        flag = 0
        break
if flag and (dist < X):
    count -= 1

print(count)
