#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,C;
	cin>>n>>C;
	vvi dp(10010,vi(101,-1));
	dp[0][0]=0;
	rep(q,n){
		vvi ndp=dp;
		int a,b,c;
		cin>>a>>b>>c;
		rep(i,10010)rep(j,101){
			if(j+c>C)continue;
			if(dp[i][j]==-1)continue;
			int A=i+a;
			int B=dp[i][j]+b;
			ndp[max(A,B)][j+c]=max(ndp[max(A,B)][j+c],min(A,B));
			A=i+b;
			B=dp[i][j]+a;
			ndp[max(A,B)][j+c]=max(ndp[max(A,B)][j+c],min(A,B));
		}
		dp=ndp;
	}
	int out=0;
	rep(i,10010)rep(j,101)out=max(out,dp[i][j]);
	cout<<out<<endl;
}