#include #include #include #include #include #include #include #include #include #include #include const int MOD = 1e9 + 7; const int iINF = 100000000; #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using ll = long long int; using P = pair; using edge = struct{int to; int cost;}; int main() { int N, K, a[21]; cin >> N >> K; rep(i, N) cin >> a[i]; ll ans = 0LL; for(int i = 0; i < (1 << N); i++) { ll tmp = 0LL; rep(j, N) { if(i & (1 << j) && (tmp + a[j] <= K)) tmp += a[j]; } ans = max(tmp, ans); } cout << ans << endl; return 0; }