#include <bits/stdc++.h>
using namespace std;
int N;
int in[502], out[502], W[502], S[502], V[502];
int getmax[502][1002];
vector<int> in1[502], in2[502];
int getMax(int x, int w) {
  if (getmax[x][w] != -1) return getmax[x][w];
  if (w < W[x]) return 0;
  getmax[x][w] = V[x];
  vector<pair<int, int> > rem1, rem2;
  for (auto i : in1[x]) {
    int val = getMax(i, min(w - W[x], S[x]));
    if (val != 0) rem1.push_back(make_pair(i, val));
  }
  for (auto i : in2[x]) {
    int val = getMax(i, min(w - W[x], S[x]));
    if (val != 0) rem2.push_back(make_pair(i, val));
  }
  vector<int> D(N + 1);
  int maxadd = 0, till = 0, maxtill = 0;
  for (int i = 0; i < int(rem1.size()); ++i) {
    D[rem1[i].first] = rem1[i].second;
    while (till < int(rem2.size()) &&
           out[rem2[till].first] <= in[rem1[i].first]) {
      maxtill = max(maxtill, D[rem2[till].first]);
      ++till;
    }
    D[rem1[i].first] += maxtill;
    maxadd = max(maxadd, D[rem1[i].first]);
  }
  getmax[x][w] = V[x] + maxadd;
  return getmax[x][w];
}
bool compare1(const int& i1, const int& i2) { return in[i1] < in[i2]; }
bool compare2(const int& i1, const int& i2) { return out[i1] < out[i2]; }
int main() {
  cin.sync_with_stdio(false);
  cin >> N >> S[0];
  for (int i = 1; i <= N; ++i) cin >> in[i] >> out[i] >> W[i] >> S[i] >> V[i];
  in[0] = 0, out[0] = 2 * N + 1;
  for (int i = 0; i <= N; ++i) {
    for (int j = 1; j <= N; ++j)
      if (i != j && in[i] <= in[j] && out[j] <= out[i]) {
        in1[i].push_back(j);
        in2[i].push_back(j);
      }
    sort(in1[i].begin(), in1[i].end(), compare1);
    sort(in2[i].begin(), in2[i].end(), compare2);
  }
  memset(getmax, -1, sizeof(getmax));
  cout << getMax(0, S[0]) << '\n';
}
