N, V = list(map(int, input().split()))
C = filter(lambda x: x<=V, map(int, input().split()))
C = list(C)
N = len(C)

cnt = 0
for c in sorted(C):
  if V>0 and V-c>=0:
    cnt += 1
    V -= c
  if V<=0:
    break
print(cnt)
