#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fast			ios_base::sync_with_stdio(0);cin.tie(0)
#define f0(a,b,c) 		for(int a=b;a<c;a++)
#define re(a,b,c) 		for(int a=b;a>=c;a--)
#define trav(a,x)		for(auto &a:x)
#define ini(a,x)		memset(a,x,sizeof(a))
#define pb 				push_back
#define eb				emplace_back
#define fi 				first
#define se 				second
#define all(con) 		con.begin(),con.end()
#define rall(con)		con.rbegin(),con.rend()
#define ll 				long long
#define vi 				vector<int> 
#define vll 			vector<ll>
#define MOD 			1000000007
#define pi 				pair<int,int>
#define pll 			pair<ll,ll>
#define mi 				map<int,int> 
#define mll				map<ll,ll>
#define umi 			unordered_map<int,int>
#define umll 			unordered_map<ll,ll>
#define lb 				lower_bound
#define ub 				upper_bound
#define pq 				priority_queue<ll,ll>
#define st				stack<int>
#define qu				queue<int>
#define endl            "\n"
#define sz(a)			(int)a.size()
using ull = unsigned long long;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}
 
template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}
 
template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

ll powm(ll a , ll n)
{
	ll res = 1;
	
	while(n)
	{
		if(n & 1)
		res = (res * a);
		
		n >>= 1;
		a = (a * a);
	}
	
	return res;
}

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
ll rev(ll x) {
	return bin_pow(x, MOD - 2);
}
struct{
    int x1,y1,x2,y2,x3,y3;
} m;
int main()
{
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
	  ll n,x;
	  cin>>n>>x;
	  vll a(n);
	  f0(i,0,n) cin>>a[i];
	  int k=n/2;
	  ll ans=0;
	  set<ll,greater<ll>> possible;
	  f0(i,0,(1<<k))
	  {
	      ll temp=0;
	      f0(j,0,k)
	      {
	          if(i >> j & 1)
	           {
	               temp+=a[j];
	           }
	      }
	      if(temp<=x)
	      {
	          possible.insert(temp);
	          chkmax(ans,temp);
	      }
	  }
	  k=n-k;
	  f0(i,0,(1<<k))
	  {
	      ll temp=0;
	      f0(j,0,k)
	      {
	          if(i >> j & 1)
	          {
	              temp+=a[n/2+j];
	          }
	      }
	      if(temp<=x)
	      {
	          chkmax(ans,temp);
	      }
	      auto y=possible.lb(x-temp);
	      if(y!=possible.end())
	        chkmax(ans,temp + *y);
	  }
	  cout<<ans<<endl;
	}
	return 0;
}
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main() {
	int N,T;
	int a[45];
	cin>>N>>T;
	for(int i=0; i<N; i++) cin>>a[i];
	vector<ll> p(1<<N/2),q(1<<(N-N/2));
	for(int i=0; i<1<<(N/2); i++) {
		for(int j=0; j<N/2; j++)
		{
			if( i & 1<<j ) {
				p[i]+=a[j];
			}
		}
	}
	for(int i=0; i<1<<(N-N/2); i++) {
		for(int j=0; j<N-N/2; j++)
		{
			if( i & 1<<j ) {
				q[i]-=a[N/2+j];
			}
		}
	}
	sort(q.begin(), q.end());
	ll ans = 0;
	for(int i=0; i<p.size(); i++) {
		if(T<p[i]) continue;
		int L = 0; int R = q.size()-1;
		int idx = lower_bound(q.begin(), q.end(), -T+p[i]) - q.begin();
		ans = max(ans, -q[idx]+p[i]);
	}
	cout<<ans<<endl;
}
