# _*_ coding:utf-8 _*_

#  Atcoder_Beginners_Contest-

#  Atcoder_Grand_Contest-

#  TODO https://atcoder.jp/contests/abc/tasks/abc_

import time

from contextlib import contextmanager

# from time import sleep

@contextmanager

def timer(title):

	t0 = time.time()

	yield

	print(("{} - done in {:.0f}s".format(title,time.time()-t0) ))



def  countJoyChild(haveCookie,joyMeterList):

	joyMeterList.sort()

	childsCount = len(joyMeterList)

	sendCookieRangeMax = list(range(0,childsCount,+1))

	sendCookieChilds = 0

	for i in sendCookieRangeMax :

		haveCookie = haveCookie-joyMeterList[i]

		if 0 <= haveCookie:

			sendCookieChilds = sendCookieChilds + 1

		else:

			break

	if 0 < haveCookie: # => 最後の一人が多すぎる

		sendCookieChilds = sendCookieChilds - 1



	answer = sendCookieChilds

	return answer





if __name__ == '__main__':

	_,X = list(map(int,input().strip().split(' ')))

	A = list(map(int,input().strip().split(' ')))

#	with timer("countJoyChild"):

	solution=countJoyChild(X,A)

	print(("{}".format(solution)))
# _*_ coding:utf-8 _*_

#  Atcoder_Grand_Contest027-a

#  https://atcoder.jp/contests/agc027/tasks/agc027_a



def  countJoyChild(haveCookie,joyMeterList):

	joyMeterList.sort()

	childsCount = len(joyMeterList)

	sendCookieRangeMax = list(range(0,childsCount,+1))

	sendCookieChilds = 0

	for i in sendCookieRangeMax :

		haveCookie = haveCookie-joyMeterList[i]

		if 0 <= haveCookie:

			sendCookieChilds = sendCookieChilds + 1

		else:

			break

	if 0 < haveCookie: # => 最後の一人が多すぎる

		sendCookieChilds = sendCookieChilds - 1



	answer = sendCookieChilds

	return answer





if __name__ == '__main__':

	_,X = list(map(int,input().strip().split(' ')))

	A = list(map(int,input().strip().split(' ')))

	solution=countJoyChild(X,A)

	print(("{}".format(solution)))
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest-
#  Atcoder_Grand_Contest-
#  TODO https://atcoder.jp/contests/abc/tasks/abc_
import time
from contextlib import contextmanager

# from time import sleep
@contextmanager
def timer(title):
    t0 = time.time()
    yield
    print(("{} - done in {:.0f}s".format(title, time.time() - t0)))


def countJoyChild(haveCookie, joyMeterList):
    joyMeterList.sort()
    childsCount = len(joyMeterList)
    sendCookieRangeMax = list(range(0, childsCount, +1))
    sendCookieChilds = 0
    for i in sendCookieRangeMax:
        haveCookie = haveCookie - joyMeterList[i]
        if 0 <= haveCookie:
            sendCookieChilds = sendCookieChilds + 1
        else:
            break
    if 0 < haveCookie:  # => 最後の一人が多すぎる
        sendCookieChilds = sendCookieChilds - 1
    answer = sendCookieChilds
    return answer


if __name__ == "__main__":
    _, X = list(map(int, input().strip().split(" ")))
    A = list(map(int, input().strip().split(" ")))
    # 	with timer("countJoyChild"):
    solution = countJoyChild(X, A)
    print(("{}".format(solution)))

# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest027-a
#  https://atcoder.jp/contests/agc027/tasks/agc027_a
def countJoyChild(haveCookie, joyMeterList):
    joyMeterList.sort()
    childsCount = len(joyMeterList)
    sendCookieRangeMax = list(range(0, childsCount, +1))
    sendCookieChilds = 0
    for i in sendCookieRangeMax:
        haveCookie = haveCookie - joyMeterList[i]
        if 0 <= haveCookie:
            sendCookieChilds = sendCookieChilds + 1
        else:
            break
    if 0 < haveCookie:  # => 最後の一人が多すぎる
        sendCookieChilds = sendCookieChilds - 1
    answer = sendCookieChilds
    return answer


if __name__ == "__main__":
    _, X = list(map(int, input().strip().split(" ")))
    A = list(map(int, input().strip().split(" ")))
    solution = countJoyChild(X, A)
    print(("{}".format(solution)))

-#  Atcoder_Beginners_Contest- -#  Atcoder_Grand_Contest- -#  TODO https://atcoder.jp/contests/abc/tasks/abc_ -import time -from contextlib import contextmanager - -# from time import sleep -@contextmanager -def timer(title): -    t0 = time.time() -    yield -    print(("{} - done in {:.0f}s".format(title, time.time() - t0))) - - +#  Atcoder_Grand_Contest027-a +#  https://atcoder.jp/contests/agc027/tasks/agc027_a -    # 	with timer("countJoyChild"):