#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10, MAXL = 500 + 10;
int n, S, in[MAXN], out[MAXN], w[MAXN], s[MAXN], v[MAXN];
int id[MAXN], h[MAXN][MAXN], g[MAXN][MAXN], f[MAXL][MAXN], Tohka;
vector<int> l[MAXN];
bool cmp(int first, int second) {
  if ((out[first] - in[first]) != (out[second] - in[second]))
    return (out[first] - in[first]) < (out[second] - in[second]);
  return (s[first] + w[first]) < (s[second] + w[second]);
}
int main() {
  scanf("%d%d", &n, &S);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d%d%d%d", &in[i], &out[i], &w[i], &s[i], &v[i]), ++in[i],
        id[i] = i;
  ++n;
  in[n] = 1, out[n] = n * 2 + 1, w[n] = 0, s[n] = S;
  id[n] = n;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1; i <= n; ++i) l[out[id[i]]].push_back(id[i]);
  for (int t = 1; t <= n; ++t) {
    int i = id[t], R = min(S - w[i], s[i]);
    for (int k = 0; k <= R; ++k) g[in[i] - 1][k] = 0;
    for (int j = in[i]; j <= out[i]; ++j) {
      for (int k = 0; k <= R; ++k) g[j][k] = g[j - 1][k];
      vector<int> &L = l[j];
      for (int p = 0; p < (int)L.size() && L[p] != i && in[L[p]] >= in[i]; ++p)
        for (int k = w[L[p]]; k <= R; ++k)
          g[j][k] = max(g[j][k], g[in[L[p]] - 1][k] + f[L[p]][k]);
    }
    for (int k = R; k >= 0; --k)
      f[i][k + w[i]] = g[out[i]][k] + v[i], Tohka = max(Tohka, f[i][k + w[i]]);
    for (int k = 0; k < w[i]; ++k) f[i][k] = 0;
    for (int k = 1; k <= S; ++k) f[i][k] = max(f[i][k], f[i][k - 1]);
  }
  cout << Tohka << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}
