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

a_s = input().split()
for i in range(N):
  a_s[i] = int(a_s[i])
  
a_s = sorted(a_s)

ans = 0
sum_ = 0
for i in range(N):
  if sum_ + a_s[i] <= x:
    sum_ += a_s[i]
    ans += 1
  else:
    break
print(ans)