from itertools import combinations def main(): N, K = map(int, input().split()) A = tuple(int(input()) for _ in [0] * N) weight = 0 for i in range(1, N + 1): comb = combinations(A, i) for j in comb: w = sum(j) if w <= K: weight = max(w, weight) print(weight) main()