N,x=map(int,input().split())
a=list(input().split())
Y=0
import itertools
A=[1,0]
B={}
C={}
max=0
for i in itertools.product(A, repeat=N):
  B[i]=i.count(1)
  
for k, v in sorted(B.items(), key=lambda x: -x[1]):
  C[k]=v

for k, v in C.items():
      
    sum=0
    for j in range(N):
        sum=sum+k[j]*int(a[j])
    if sum==x:
        max=v
        Y=1
        break
    if Y==2:
        Y=1
        break
    if sum<x and v>0:
        max=v-1
        Y=2 
  

print(max)