#include <bits/stdc++.h>

typedef long long ll; 

using namespace std;

//const int MAX=INT_MAX;

const ll MAX=100000000000;

const int mod = 1000000007;
//const int mod = 998244353;

int main(){

    int N;
    cin>>N;
    ll T;
    cin>>T;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    int M=N/2;

    vector<ll> A1;
    vector<ll> A2;

    for(int i=0;i<(1<<M);i++){
        int bit[22];
        ll sum=0;
        for(int j=0;j<M;j++){
            int Div=(1<<j);
            bit[j]=(i/Div)%2;
        }

        for(int j=0;j<M;j++){
            sum+=A[j]*bit[j];
        }
        //cout<<sum<<endl;

        A1.push_back(sum);
    }

    for(int i=0;i<(1<<(N-M));i++){
        int bit[22];
        ll sum=0;
        for(int j=0;j<N-M;j++){
            int Div=(1<<j);
            bit[j]=(i/Div)%2;
        }

        for(int j=0;j<N-M;j++){
            sum+=A[j+M]*bit[j];
        }
        //cout<<sum<<endl;
        A2.push_back(sum);
    }

    sort(A1.begin(),A1.end());
    sort(A2.begin(),A2.end());
/*
    for(ll i=0;i<A1.size();i++){
        cout<<A1[i]<<" ";
    }
    cout<<endl;
     for(ll i=0;i<A2.size();i++){
        cout<<A2[i]<<" ";
    }
    cout<<endl;
*/
    ll ans=0;

    for(ll i=0;i<A2.size();i++){
          if(T-A2[i]<0){
            break;
        }


        auto itr=lower_bound(A1.begin(),A1.end(),T-A2[i]);

       // cout<<*itr<<":"<<T-A2[i]<<":"<<distance(A1.begin(),itr)<<endl;

      
        if(itr==A1.end()){
            itr=prev(itr);
            //cout<<"prev"<<*itr<<endl;
            ans=max(*itr+A2[i],ans);

        }else if((*itr)+A2[i]==T){
            ans=T;

            break;
        }else{
            if(itr!=A1.begin()){
                 itr=prev(itr);
                 ans=max(*itr+A2[i],ans);

            }else{
                ans=max(A2[i],ans);
            }
        
        }

    }

    cout<<ans<<endl;

}
#include <algorithm>
#include <iostream>
int n, t, ans, a[45];
long long suf[45];
void dfs(int k, long long sum) {
	if(k > n) return;
	if(t - sum > ans)
		ans = t - sum;
	else if(t - sum + suf[k + 1] <= ans)
		return;
	if(!sum) {
		printf("%lld", t);
		exit(0);
	}
	if(sum - a[k + 1] >= 0) dfs(k + 1, sum - a[k + 1]);
	dfs(k + 1, sum);
}

const bool cmp(int x, int y) {
	return x > y;
}

int main() {
	scanf("%d%d", &n, &t);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	std::sort(a + 1, a + n + 1, cmp);
	for(int i = n; i >= 1; i--) suf[i] = suf[i + 1] + a[i];
	dfs(0, t);
	printf("%lld", ans);
	return 0;
}