#include #include void solve() { int n, k; std::cin >> n >> k; std::vector xs(n); for (auto& x : xs) std::cin >> x; int ans = 0; for (int b = 0; b < (1 << n); ++b) { int s = 0; for (int i = 0; i < n; ++i) { if ((b >> i) & 1) s += xs[i]; } if (s <= k) ans = std::max(ans, s); } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }