#include <bits/stdc++.h>
using namespace std;
const int MaxV = 500 * 2 + 10;
int f[MaxV][MaxV], g[MaxV][MaxV];
bool vis[MaxV][MaxV], inq[MaxV];
int head[MaxV], nxt[MaxV], to[MaxV], tid[MaxV], tsd[MaxV], twd[MaxV], tvd[MaxV],
    in, out, si, vi, wi, n, S, top;
void addedge(int fr, int tt, int ww, int ss, int vv, int id) {
  top++;
  nxt[top] = head[fr];
  to[top] = tt;
  tid[top] = id;
  tsd[top] = ss;
  twd[top] = ww;
  tvd[top] = vv;
  head[fr] = top;
}
int dp(int id, int st, int en, int s) {
  if (vis[id][s]) return f[id][s];
  vis[id][s] = 1;
  int &ret = f[id][s];
  ret = 0;
  inq[id] = 1;
  memset(g[id], 0, sizeof(g[id]));
  for (int i = st; i <= en; i++) {
    g[id][i] = g[id][i - 1];
    for (int j = head[i]; j; j = nxt[j])
      if (!inq[tid[j]] && to[j] >= st && s - twd[j] >= 0)
        g[id][i] =
            max(g[id][i], g[id][to[j]] +
                              dp(tid[j], to[j], i, min(tsd[j], s - twd[j])) +
                              tvd[j]);
  }
  inq[id] = 0;
  return ret = g[id][en];
}
int main() {
  scanf("%d%d", &n, &S);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d%d", &in, &out, &si, &vi, &wi);
    addedge(out, in, si, vi, wi, i);
  }
  printf("%d", dp(0, 0, 1000, S));
  return 0;
}
