n,x=map(int,input().split())
a=list(map(int,input().split()))
happy=[]
for i in range(2**n):
    cnt=0
    ans=0
    for j in range(n):
        if ((i>>j)&1):
            cnt+=a[j]
            ans+=1
    if cnt==x:
        happy.append(ans)
    elif cnt<x:
        if 1<=ans:
            happy.append(ans-1)
        else:
            happy.append(0)
print(max(happy))