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