#include #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for(int i = (s); i < (int)(n); i++) #define printYN(check) cout << ((check)? "Yes" : "No") << endl #define NUM 998244353 using namespace std; using vi = vector; using vvi = vector; using ll = long long; using vl = vector; using vvl = vector; using vs = vector; using vb = vector; using vvb = vector; using pii = pair; using vpii = vector; using tii = tuple; using Graph = vvi; // Graph graph(n); // vi dx = {-1, 0, 1, -1, 1, -1, 0, 1}; // vi dy = { 1, 1, 1, 0, 0, -1, -1,-1}; // snippet -> {UnionFind, dfs_reculsive, dfs_stack, is_prime, // bfs_queue, digsum, binary_search, gcd, Dijkstra, bitsearch} // -------------------------------------------------------------------------- int main() { int n, k; cin >> n >> k; vi arr(n); rep(i, n) { cin >> arr[i]; } set ans; rep(i, (1< bits(i); int sum = 0; rep(j, n) { if(bits.test(j)) { sum += arr[j]; } } if(sum <= k) { ans.insert(sum); } } cout << *ans.rbegin() << endl; return 0; }