n,x = map(int,input().split())
arr = list(map(int,input().split()))
ans = 0;
arr.sort();

for i in range(n):

	if x < arr[i]:
		break;
	else:
		ans+=1;
		x -= arr[i];

if x > 0 and ans > 0:
	ans-=1;

print(ans);