# -*- coding: utf-8 -*-
N,x = input().split()
N = int(N)
x = int(x)

a = input().split()

a = sorted(a)

xnum = 0
total = 0
for ax in a:
    total = total + int(ax)
    if (total <= x):
        xnum = xnum + 1

if (total < x):
    xnum = xnum - 1
print(xnum)
