#include <bits/stdc++.h>
using namespace std;
// #define int long long 
typedef pair<int, int> pii; 
#define ll long long
#define ar array
const ll mxN=300;
const int mod=1e9+7;
const ll INF=1e18;
#define what_is(x) cerr << #x << " is " << x << endl;

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

	vector<int> L,R;
	
	int l=n/2,r=n-l;
	// left part
	for(int i=0;i<(1<<l);i++){
		int s=0;
		for(int j=0;j<l;j++){
			if(i&(1<<j)){
				s+=a[j];
			}

			if(s>t){
				break;
			}
		}
		if(s<=t){
			
			L.push_back(s);
		}
	}

	// right part
	for(int i=0;i<(1<<r);i++){
		int s=0;
		for(int j=0;j<r;j++){
			if(i&(1<<j)){
				s+=a[j+l];
			}
			
			if(s>t){
				break;
			}
		}
		if(s<=t){
		
			R.push_back(s);
		}
	}
	sort(R.begin(),R.end());
	sort(L.begin(),L.end());
	int ans=0;
	
	for(int li: L){
		auto it= lower_bound(R.begin(),R.end(),t-li+1) - R.begin();
		if(it==R.size()); it--;
			ans=max(ans,li+R[it]);
	}

	cout<<ans<<endl;



}
 
 
signed main() {
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<setprecision(12)<<fixed;
    
    int t;
    // cin>>t;
    // while(t--)
    	solve();
	return 0;
   
}  
#include<bits/stdc++.h>

#define DONTSYNC ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now!
#define TEST unsigned long long T; cin>>T; while(T--)  //loop over each testcase
#define endl "\n"
#define fori(a,start,end) for(int a=start;a<end;a++)
#define forll(a,start,end) for(long long a=start;a<end;a++)
#define forull(a,start,end) for(unsigned long long a=start;a<end;a++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

void solve(){
    /* code */
    ll N,K; cin>>N>>K;
    ll res=0;
    forll(val,2,2*N+1){
        if(val-K<2 || val-K>2*N)  continue;
        ll waysab=(val<=N)?(val-1):(2*N+1-val);
        ll wayscd=(val-K<=N)?(val-K-1):(2*N+1-val+K);
        res+=waysab*wayscd;
    }
    cout<<res;
}

int main()
{
    DONTSYNC;
    // TEST{
        solve();
    // }
    return 0;
}
