#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct Counter
{
static int k;
Counter() {k++;}
~Counter() {k--;}
};
int Counter::k = 0;
template<typename T>
void pr(const string& name, T t)
{
cout << name << " = " << t << endl;
}
template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest)
{
auto comma_pos = names.find(',');
cout << names.substr(0, comma_pos) << " = " << t << ", ";
auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
pr(string(names, next_name_pos), rest ...);
}
void mod(ll &a, ll b)
{
a %= b;
if(a < 0) a += b;
}
#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define trace(...) pr(#__VA_ARGS__, __VA_ARGS__);
#define tracea(x) {string s = #x; Counter c##x; cout<<s.substr(0,1+s.find('['))<<Counter::k<<"]="<<x<<'\n';}
#define vii vector<pair<int,int>>
const ll MOD = 1000000007;
// ----------------------------------------------------------------------------------------------------------
ifstream fin("guard.in");
ofstream fout("guard.out");
struct Cow
{
ll h, w, str;
Cow(ll p1, ll p2, ll p3) : h(p1), w(p2), str(p3) {};
friend bool operator < (Cow c1, Cow c2)
{
return c1.str > c2.str;
}
};
const ll INF = 1000000000000000000ll;
ll N, J, Rem[1100000], H[1100000];
vector<Cow> V;
int main()
{
fin >> N >> J;
f(i,1,N)
{
ll h, w, str;
fin >> h >> w >> str;
V.pb(Cow(h,w,str));
}
ll ans = -1;
Rem[0] = INF;
f(m,1,(1<<N)-1) Rem[m] = -INF;
f(m,0,(1<<N)-1)
{
if(H[m] >= J) ans = max(ans, Rem[m]);
f(i,0,N-1) if(!(m&(1<<i)))
{
ll next_rem = min(Rem[m] - V[i].w, V[i].str);
ll next_h = H[m] + V[i].h;
ll next_mask = m + (1<<i);
H[next_mask] = next_h;
Rem[next_mask] = max(Rem[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Q293PiBWOwoKaW50IG1haW4oKQp7CiAgICBmaW4gPj4gTiA+PiBKOwoKICAgIGYoaSwxLE4pCiAgICB7CiAgICAgICAgbGwgaCwgdywgc3RyOwogICAgICAgIGZpbiA+PiBoID4+IHcgPj4gc3RyOwogICAgICAgIFYucGIoQ293KGgsdyxzdHIpKTsKICAgIH0KCiAgICBsbCBhbnMgPSAtMTsKICAgIFJlbVswXSA9IElORjsKCiAgICBmKG0sMSwoMTw8TiktMSkgUmVtW21dID0gLUlORjsKCiAgICBmKG0sMCwoMTw8TiktMSkKICAgIHsKICAgICAgICBpZihIW21dID49IEopIGFucyA9IG1heChhbnMsIFJlbVttXSk7CiAgICAgICAgZihpLDAsTi0xKSBpZighKG0mKDE8PGkpKSkKICAgICAgICB7CiAgICAgICAgICAgIGxsIG5leHRfcmVtID0gbWluKFJlbVttXSAtIFZbaV0udywgVltpXS5zdHIpOwogICAgICAgICAgICBsbCBuZXh0X2ggPSBIW21dICsgVltpXS5oOwogICAgICAgICAgICBsbCBuZXh0X21hc2sgPSBtICsgKDE8PGkpOwogICAgICAgICAgICBIW25leHRfbWFza10gPSBuZXh0X2g7CiAgICAgICAgICAgIFJlbVtuZXh0X21hc2tdID0gbWF4KFJlbVtuZXh0X21hc2tdLCBuZXh0X3JlbSk7CiAgICAgICAgfQogICAgfQoKICAgIGlmKGFucyA+PSAwKSBmb3V0IDw8IGFuczsKICAgIGVsc2UgZm91dCA8PCAiTWFyayBpcyB0b28gdGFsbCI7Cn0K