n,x = map(int,input().split())
a = [int(i) for i in input().split()]
flag = False
for bit in range(1<<n):
    ans = []
    for i in range(n):
        mask = 1<<i
        if mask&bit:
            ans.append(a[i])
    if sum(ans)==x:
        flag = True
        break
if not flag:    
    a_new = sorted(a)
    i = 0
    while x>=0 and i < n:
        if x >= a_new[i]:
            x -= a_new[i]
        else:
            break
        i += 1
    if x>0 and i>0:
        i -= 1
    print(i)
else:
    print(len(ans))