import itertools n, k = map(int, input().split()) ans = 0 alst = [int(input()) for _ in range(n)] for lst in itertools.product([True, False], repeat = n): cnt = 0 for t, a in zip(lst, alst): if t: cnt += a if cnt <= k: ans = max(ans, cnt) print(ans)