#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	int n, t; cin >> n >> t;
	vector<int> left, right;

	for (int i = 0; i <= n - 1; i++) {
		int a; cin >> a;
		if (i <= n / 2) left.emplace_back(a);
		else right.emplace_back(a);
	}

	auto subseq = [&](const vector<int>& v) -> vector<long long> {
		vector<long long> res;
		for (int mask = 0; mask < 1 << (int)v.size(); mask++) {
			long long curr = 0;
			for (int j = 0; j < v.size(); j++) {
				if (mask & (1 << j)) curr += v[j];
			}
			res.emplace_back(curr);
		}
		sort(res.begin(), res.end());
		return res;
	};

	vector<long long> ff = subseq(left);
	vector<long long> ss = subseq(right);

	long long ans = 0;
	for (auto i : ff) {
		auto it = upper_bound(ss.begin(), ss.end(), t - i);
		if (it == ss.begin()) continue;
		ans = max(ans, i + *prev(it));
	}

	cout << ans;


	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,-1,1};
ll dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n,t; cin >> n >> t;
    vl a(n); rep(i,n) cin >> a[i];
    vl ls1, ls2;
    int N = n/2;
    rep(bit,1<<N){
        ll s = 0;
        rep(i,N) if(bit>>i & 1) s += a[i];
        ls1.push_back(s);
    }
    rep(bit,1<<(n-N)){
        ll s = 0;
        rep(i,n-N) if(bit>>i & 1) s += a[i+N];
        ls2.push_back(s);
    }
    sort(rall(ls1));
    sort(all(ls2));
    ll ans = 0;
    int id = 0;
    int m = ls2.size();
    for(auto x : ls1){
        if(x > t) continue;
        while(id < m-1 && ls2[id+1] + x <= t) id++;
        if(id < m) chmax(ans, ls2[id] + x);
    }
    cout << ans << "\n";
}