#include <bits/stdc++.h>
using namespace std;
vector<int> h[1010];
int d[1010][1010], out[1010], D[1010], in[1010], w[1010], v[1010], s[1010], n;
int go(int i, int sum) {
  if (sum < 0) return 0;
  if (d[i][sum] >= 0) return d[i][sum];
  int cs = min(sum, s[i]);
  for (int x = in[i]; x <= out[i]; ++x) {
    for (vector<int>::iterator it = h[x].begin(); it != h[x].end(); it++)
      if (*it != i && out[*it] <= out[i]) go(*it, cs - w[*it]);
  }
  for (int x = in[i]; x <= out[i]; ++x) D[x] = 0;
  for (int x = in[i]; x <= out[i]; ++x) {
    D[x + 1] = max(D[x], D[x + 1]);
    for (vector<int>::iterator it = h[x].begin(); it != h[x].end(); it++)
      if (*it != i && out[*it] <= out[i])
        D[out[*it]] = max(D[out[*it]], D[x] + go(*it, cs - w[*it]));
  }
  d[i][sum] = v[i] + D[out[i]];
  return d[i][sum];
}
int main() {
  cin >> n >> s[0];
  for (int i = 1; i <= n; ++i) {
    cin >> in[i] >> out[i] >> w[i] >> s[i] >> v[i];
    h[in[i]].push_back(i);
  }
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= s[0]; ++j) d[i][j] = -1;
  out[0] = 2 * n + 1;
  cout << go(0, s[0]);
  return 0;
}
