//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int a[2621500];

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N, T;
	scanf("%d %d ", &N, &T);
	int A[50];
	rep(i, N) scanf("%d ", A + i);

	auto mae = a, ato = a + (1 << 20) + 1, sub = a + (1 << 21) + 2;

	int X = 1;
	rep(i, N / 2) {
		int x = 0, y = 0, z = 0;
		mae[X] = 2000000000;
		rep(x, X) {
			while (mae[y] < mae[x] + A[i]) sub[z++] = mae[y++];
			sub[z++] = mae[x] + A[i];
		}
		X <<= 1;
		while (sub[X - 1] > T) X--;
		swap(mae, sub);
	}
	int Y = 1;
	for (int i = N / 2; i < N; i++) {
		int x = 0, y = 0, z = 0;
		ato[Y] = 2000000000;
		rep(x, Y) {
			while (ato[y] < ato[x] + A[i]) sub[z++] = ato[y++];
			sub[z++] = ato[x] + A[i];
		}
		Y <<= 1;
		while (sub[Y - 1] > T) Y--;
		swap(ato, sub);
	}


	int j = Y - 1;
	ll kotae = 0;
	rep(i, X) {
		ll tmp = mae[i];
		while (j >= 0 && tmp + ato[j] > T) j--;
		if (j < 0) break;
		if (kotae < tmp + ato[j]) kotae = tmp + ato[j];
	}

	printf("%lld\n", kotae);


	Would you please return 0;
}
#include<bits/stdc++.h>
#define ll long long int
#define inf 1E18
#define ninf -1*1E18
#define mod 1000000007
#define fi first
#define si second
#define pb push_back
#define vi vector<long long int>
#define pi pair<long long int,long long int>
#define vpi vector<pair<long long int,long long int>>
using namespace std;
ll const lac = 100000;

ll modmul(ll a, ll b) {

	return ((a % mod) * (b % mod)) % mod;

}
ll modadd(ll a, ll b) {
	return (((a % mod) + (b % mod))) % mod;
}
long long modExpo(long long a, long long b, long long m) {

	long long result = 1;
	a = a % m;
	while (b > 0) {

		if (b % 2) {

			result = modmul(result, a);
			b--;
		}

		else {
			a = modmul(a, a);
			b /= 2;
		}


	}


	return result % m;
}


ll gcd(ll a, ll b) {
	if (b == 0) return a; else return gcd(b, a % b);
}

class comp {   //set of pairs comparator:
public:
	bool operator()(int a, int b)const {


		return a > b;


	}

};

bool compa(int a, int b) {
	return a > b;
}





void solve(ll t1) {


	ll a1, b, c;
	cin >> a1 >> b >> c;

	vi a;
	a.pb(a1); a.pb(b); a.pb(c);
	sort(a.begin(), a.end());
	cout << a[2] + a[1] << "\n";















}





int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t ;
	t = 1;



	// init();
	// cin >> t;



	for (ll i = 1; i <= t; i++) {



		solve(t);
	}



	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;

	return 0;
}