#include #include #include using namespace std; #define FOR(i, a, n) for (int i = a; i < n; i++) #define REP(i, n) for(int i = 0; i < n; i++) struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star; int main(){ int n, k; cin >> n >> k; vector A(n); for(auto &x : A) cin >> x; int ans = INT_MIN; REP(i, (1 << n)){ bitset<5> b = i; int total = 0; REP(j, 5){ if(b[j] == 1) total += A[j]; } if(total <= k) ans = max(ans, total); } cout << ans << endl; return 0; }