N,M = map(int,raw_input().split())
C = map(int,raw_input().split())
C.sort()
count = 0
for c in C:
	M -= c
	count +=1
	if M <= 0:break
print count-1 if M < 0 else count