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

long long int a[50] = {0} , b[50] = {0};
int main() {
	// your code goes here
    int n;
    long long int t;
    cin >> n >> t;
    int x = n/2;
    for(int i = 0 ; i < x ; i++){
           cin >> a[i];
    }
    
    for(int i = 0 ; i < n-x ; i++){
        cin >> b[i];
    }
    vector<long long int > v , u;
    for(int i = 0 ; i < (1 << x) ; i++){
        long long int val = 0;
        for(int j = 0 ; j < x ; j++){
            if((i&(1<<j)))
                val += a[j];
        }
        v.push_back(val);
    }
    
    for(int i = 0 ; i < (1 << (n-x)) ; i++){
        long long int val = 0;
        for(int j = 0 ; j < (n-x) ; j++){
            if((i&(1<<j)))
                val += b[j];
        }
        u.push_back(val);
    }
    
    sort(u.begin() , u.end());
    long long int ans = 0 , k;
    for(int i = 0 ; i < v.size() ; i++){
         k = t - v[i];
         if(k <= 0) continue;
         int f = upper_bound(u.begin() , u.end() , k) - u.begin();
         f--;
         if(f < 0) continue;
         else ans = max(ans , v[i] + u[f]);
    }
    cout << ans << endl;
    
	
	return 0;
}


/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

ll n,t,w[N],ans;
void rec(int i,int n,vector<ll>&s,ll sum){
    if(i>n){
        if(sum<=t){
            ans=max(ans,sum);
            s.pb(sum);
        }
        return;
    }
    rec(i+1,n,s,sum);
    rec(i+1,n,s,sum+w[i]);
}
signed main(){
    FastIO;
    cin>>n>>t;
    rep(i,1,n) cin>>w[i];
    vector<ll>a,b;
    rec(1,n/2,a,0);
    rec(n/2+1,n,b,0);
    sort(all(a));
    sort(all(b));
    for(ll i:a){
        auto it=ub(all(b),t-i);
        if(it==b.begin()) continue;
        --it;
        if(*it+i<=t) ans=max(ans,*it+i);
    }
    cout<<ans;
    return 0;
}
