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

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

print(max)