line = input().split()
x = int(line[1])
ans = 0
 
a = sorted(input().split())
map(int, a)
 
for i in range(len(a)):
  if a[i] > x:
    print(ans)
    break
  else:
    x-=a[i]
    if i!=(len(a)-1):
      ans+=1
    else:
      if x==0:
        ans+=1
      print(ans)