#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

using VL = vector<long long>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;

VL calc(bool is_front, const VL &a) {
	int n = a.size();
	int n2 = n / 2;

	VL b;
	if (is_front) {
		for (int i = 0; i < n2; i++) {
			b.emplace_back(a[i]);
		}
	} else {
		for (int i = n2; i < n; i++) {
			b.emplace_back(a[i]);
		}
	}

	VL points;

	int nb = b.size();
	int limit = 1 << nb;
	for (int i = 0; i < limit; i++) {
		long long val = 0;
		for (int j = 0; j < nb; j++) {
			if ((i >> j) & 1) {
				val += b[j];
			}
		}
		points.emplace_back(val);
	}

	sort(points.begin(), points.end());
	return points;
}

int main() {
	int n, t;
	cin >> n >> t;

	VL a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	auto v1 = calc(true, a);
	auto v2 = calc(false, a);

	long long ans = 0;
	for (auto x: v1) {
		if (x > t) {
			break;
		}
		ans = max(ans, x);

		auto it = upper_bound(v2.begin(), v2.end(), t - x);
		if (it != v2.begin()) {
			ans = max(ans, x + *prev(it));
		}
	}

	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}
ll n,k;

void calc(ll arr[], ll x[], ll n, ll c) {
	for (int i=0; i<(1<<n); i++) { 
        ll sum = 0; 
        for (int j=0; j<n; j++) 
            if (i & (1<<j)) 
                sum += arr[j+c]; 
        x[i] = sum; 
    } 
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		cin>>n>>k;
		ll arr[n];
		ll a[2000000+10],b[2000000+10];
		f(i,n) cin>>arr[i];
		calc(arr,a,n/2,0);
		calc(arr,b,n-n/2,n/2);
		int sa = 1<<(n/2); 
    	int sb = 1<<(n-n/2); 
  
	    sort(b, b+sb); 
	    ll max = 0; 
	    f(i,sa) { 
	        if (a[i] <= k) {  
	            int p = lower_bound(b, b+sb, k-a[i]) - b; 
	  
	            if (p == sb || b[p] != (k-a[i])) 
	                p--; 
	  
	            if ((b[p]+a[i]) > max) 
	                max = b[p]+a[i]; 
	        } 
	    } 
	    cout<<max<<"\n";
	}
 	return 0;
}
