#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=42;
int a[N];

void slv(int l,int r,int sum,vector <int> &v){
	if(l>r){
		v.pb(sum);
		return;
	}
	slv(l,r-1,sum+a[r],v);
	slv(l,r-1,sum,v);
}

int32_t main(){
   ios;
  	int n,t;
  	cin>>n>>t;
  	F(i,1,n) cin>>a[i];

  	vector <int> u,v;
  	slv(1,n/2,0,v);
  	slv(n/2+1,n,0,u);

  	sort(all(v));
  	int ans=0;
  	for(auto it:u){
  		if(it>t) continue;
  		int val=it;
  		int x=upper_bound(all(v),t-it)-v.begin()-1;
  		if(x>=0) val+=v[x];
  		ans=max(ans,val);
  	}
  	cout<<ans<<endl;
}

#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template<typename T = int> using V = vector<T>;
template<typename T = int> using VV = vector<vector<T>>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
#ifdef DEBUG
template<typename T>
ostream &operator<<(ostream &os, set<T> st) {
    for(auto x : st) cerr << x << ' ';
    return os;
}
template<typename T, typename S>
ostream &operator<<(ostream &os, map<T, S> mp) {
    for(auto x : mp) cerr << x << ' ';
    return os;
}
#endif
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    ll t;
    cin >> n >> t;
    vector<ll>a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    vector<ll> b;
    for(int i = 0; i < 1 << (n / 2); i++){
        ll sum = 0;
        for(int j = 0; j < n / 2; j++){
            if(i >> j & 1)sum += a[j];
        }
        b.push_back(sum);
    }
    sort(b.begin(), b.end());
    ll ans = 0;
    for(int i = 0; i < 1 << (n - n / 2); i++){
        ll sum = 0;
        for(int j  = 0; j < n - n / 2; j++){
            if(i >> j & 1)sum += a[j + n / 2];
        }
        if(sum > t)continue;
        if(b[0] + sum > t)ans = max(ans, sum);
        int id = (int) (lower_bound(b.begin(), b.end(), t - sum) - b.begin());
        for(int x: {id-1,id,id+1}){
            if(0<=x and x < b.size() and b[x] + sum <= t)ans = max(ans, b[x] + sum);
        }
    }
    cout << ans << endl;
}
