#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, T;
int a[40];
vector<int> pre;
vector<int> suf;

void dfs(int cor, int end, int tsum, vector<int> &vec) {
	if (cor == end) {
		vec.push_back(tsum);
		return;
	}
	dfs(cor + 1, end, tsum, vec);
	dfs(cor + 1, end, tsum + a[cor], vec);
}

signed main() {
	int i, j;
	
	cin >> n >> T;
	rep(i, n) cin >> a[i];
	if (n == 1) {
		if (a[0] <= T) {
			cout << a[0] << endl;
		}
		else {
			cout << 0 << endl;
		}
		return 0;
	}
	dfs(0, n / 2, 0, pre);
	dfs(n / 2, n, 0, suf);
	sort(pre.begin(), pre.end());
	sort(suf.begin(), suf.end());
	
	int ans = 0;
	j = 0;
	for (i = (int)pre.size() - 1; i >= 0; i--) {
		if (pre[i] > T) continue;
		for (; j < (int)suf.size(); j++) {
			if (pre[i] + suf[j] > T) break;
		}
		if (j == 0) ans = max(ans, pre[i]);
		else ans = max(ans, pre[i] + suf[j - 1]);
	}
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int maxn = 40;
const int inf = 1e9;
int a[maxn];
int main(){__
	int n;
	cin >> n;
	lli t;
	cin >> t;
	for(int i=0; i < n; i++) cin >> a[i];
	int mit = n/2;
	vector<lli> izq,der;
	int uno = n/2;
	int dos = n - uno;
	for(int msk=0; msk < (1 << uno); msk++){
		lli suma = 0ll;
		for(int j=0; j < uno; j++){
			if(msk & (1 << j)){
				suma+=a[j];
			}
		}
		izq.pb(suma);
	}

	for(int msk=0; msk < (1 << dos); msk++){
		lli suma = 0ll;
		for(int j=0; j < dos; j++){
			if(msk & (1 << j)){
				suma+=a[j+uno];
			}
		}
		der.pb(suma);
	}

	sort(all(izq));
	sort(all(der));

	lli maxi = 0ll;
	for(lli x : izq){
		if(x > t) continue;
		maxi = max(maxi,x);
		int pos = upper_bound(all(der),t - x) - der.begin();
		if(pos == 0) continue;
		pos--;
		assert(der[pos] + x <= t);
		maxi = max(maxi,der[pos] + x);
	}

	for(lli x : der){
		if(x > t) continue;
		maxi = max(maxi,x);
		int pos = upper_bound(all(izq),t - x) - izq.begin();
		if(pos == 0) continue;
		pos--;
		assert(izq[pos] + x <= t);
		maxi = max(maxi,izq[pos] + x);
	}

	cout << maxi << endl;
	return 0;
}

