#yuki_617 import itertools n,k=map(int,raw_input().split()) a=[] for i in xrange(n): a.append(int(raw_input())) res=0 for i in xrange(1,n+1): c=itertools.combinations(a,i) for j in c: if sum(j)<=k: res=max(sum(j),res) print res