import itertools N, K = map(int, input().split()) l = [] ans = 0 for i in range(N): l.append(int(input())) for i in range(1, N + 1): for li in list(itertools.combinations(l,i)): if ans < sum(li) <= K: ans = sum(li) print(ans)