INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

n,x = read_ints()
a = read_ints()
a.sort()
ans = 0
for i in range(len(a)):
    if i == len(a)-1 and x == a[i]:
        ans += 1 
    elif i != len(a)-1 and a[i] <= x:
        ans += 1 
        x -= a[i] 
print ans 
