#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 = 0; REP(i, (1 << n)){ int total = 0; REP(j, i){ if((i >> j) & 1){ total += A[j]; } } if(total <= k) ans = max(ans, total); } cout << ans << endl; return 0; }