N,x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = 0
for i in range(N):
  if x-a[i] >=0:
    ans += 1
    x -= a[i]

if x == 0:
  print(ans)
else:
  print(max(0,ans-1))