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

N, x = map(int, input().split())
aList = map(int, input().split())
sortedAList = sorted(aList)

cnt = 0
for a in sortedAList:
	if x >= a:
		cnt += 1
		x   -= a
	else:
		break

if x > 0:
	cnt -= 1
	
print(cnt)
