# combinationの勉強 import itertools as it #N[0]は個数,N[1]がmaxweight N = list(map(int,input().split())) A = [0]*N[0] for i in range(N[0]): A[i] = int(input()) combi = list(it.combinations(A,0)) #print(combi) ans = 0 weight = 0 for i in range(N[0]): combi = list(it.combinations(A,i+1))#nCnにおいて後ろのnが1より大きくないと何もcombiしない #print(combi) for j in range(len(combi)): weight = sum(combi[j]) #print(weight) if (ans<=weight)and(weight<=N[1]): ans = weight print(ans)