import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,x = LI()
a = LI()
ans = 0
a.sort()
for y in a:
    if x>=y:
        x -= y
        ans += 1
    else:
        break
print(ans) 
