n,x = map(int,input().split())
a = list(map(int,input().split()))
aa = sorted(a)
nokori = x
cnt = 0
for i in range(n):
         if nokori >= a[i]:
                  cnt +=1
                  nokori = nokori - a[i]
print(cnt)
