#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
inline int Max(const int &a, const int &b) {
  if (a > b) return a;
  return b;
}
int f[N][N], g[N];
int n, S;
struct pla {
  int l, r, w, s, v, id;
} a[N];
inline bool cmp(const pla &a, const pla &b) {
  if (a.l ^ b.l) return a.l < b.l;
  return a.r > b.r;
}
vector<pla> zh[N];
int main() {
  scanf("%d%d", &n, &S);
  for (int i = (1); i <= (int)n; i++) {
    scanf("%d%d%d%d%d", &a[i].l, &a[i].r, &a[i].w, &a[i].s, &a[i].v);
    a[i].l++;
    a[i].r++;
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = (1); i <= (int)n; i++) a[i].id = i;
  for (int i = (1); i <= (int)n; i++) zh[a[i].l].push_back(a[i]);
  for (int i = (n); i >= (int)1; i--) {
    int limit = a[i].s;
    if (S - a[i].w < limit) limit = S - a[i].w;
    for (int up = (0); up <= (int)limit; up++) {
      for (int j = (a[i].l); j <= (int)a[i].r; j++) g[j] = 0;
      for (int j = (a[i].l); j <= (int)a[i].r; j++) {
        if (g[j - 1] > g[j]) g[j] = g[j - 1];
        for (vector<pla>::iterator it = zh[j].begin(); it != zh[j].end();
             it++) {
          pla u = *it;
          if (u.r > a[i].r) continue;
          if (u.w > up) continue;
          if (u.id <= i) continue;
          int pp = up - u.w;
          if (pp > u.s) pp = u.s;
          if (pp >= 0) g[u.r] = Max(g[u.r], g[j] + f[u.id][pp]);
        }
      }
      f[i][up] = g[a[i].r] + a[i].v;
      if (up)
        if (f[i][up] < f[i][up - 1]) f[i][up] = f[i][up - 1];
    }
  }
  int l = 1;
  int r = 2 * n;
  memset(g, 0, sizeof g);
  for (int i = (l); i <= (int)r; i++) {
    if (g[i] < g[i - 1]) g[i] = g[i - 1];
    for (vector<pla>::iterator it = zh[i].begin(); it != zh[i].end(); it++) {
      pla u = *it;
      int tmp = S - u.w;
      if (u.s < tmp) tmp = u.s;
      if (tmp >= 0) {
        g[u.r] = Max(g[i] + f[u.id][tmp], g[u.r]);
      }
    }
  }
  printf("%d\n", g[r]);
  return 0;
}
