n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = 0
count = 0
for i in range(n):
  if x:
  	x -= a[i]
  else:
    print(i)
    exit()
print(n if x == 0 else n-1)