#include <bits/stdc++.h>

#define ll long long

using namespace std;
vector<ll> subsets(vector<int> a){
    int n = a.size();
    vector<ll> ret;
    for(int mask = 0; mask < (1<<n); mask++){
        ll sum = 0;
        for(int i=0; i<n; i++){
            if( (mask&(1<<i)) != 0){
                sum += a[i];
            }
        }
        ret.push_back(sum);
    }
    return ret;
}
int main() {
    int n, t;
    cin>>n>>t;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    vector<int> s1(a, a+(n/2));
    vector<int> s2(a+(n/2), a+n);
    vector<ll> sum1 = subsets(s1), sum2 = subsets(s2);
    sort(sum1.begin(), sum1.end());
    sort(sum2.begin(), sum2.end());
    ll mn = 1e15;
    for(ll sum: sum1){
        if(sum > t) continue;
        ll rem = t - sum;
        auto it = upper_bound(sum2.begin(), sum2.end(), rem);
        it--;
        rem -= *it;
        mn = min(mn, rem);
    }
    cout<<t-mn<<'\n';

}
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 48
using namespace std;
ll D[limit],W;

void middle(ll pos,ll n,ll sum,vector<ll> &A)
{
    if(pos>n)
    {
        if(sum<=W) A.pb(sum);
        return ;
    }
    middle(pos+1,n,sum,A);
    middle(pos+1,n,sum+D[pos],A);
}

void solve(int t)
{
    ll n,i,j;
    scanf("%lld %lld",&n,&W);
    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&D[i]);
    }
    sort(D,D+n+1);
    vector<ll>A,B;
    A.pb(0);
    middle(1,n/2,0,A);
    middle(n/2+1,n,0,B);
    sort(A.begin(),A.end());
    ll mx=0,sz=A.size();
    for(i=B.size()-1; i>=0; i--)
    {
        n = (W-B[i]);
        ll l=0,h=sz-1,m;
        while(l<=h)
        {
            m = (l+h)/2;
            if(n>=A[m])
            {
                if((B[i]+A[m])<=W && mx<(B[i]+A[m]))
                    mx = B[i]+A[m];
                l = m+1;
            }
            else
            {
                h = m-1;
            }
        }
    }
    printf("%lld\n",mx);
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
    return 0;
}

