#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int maxN = 510;
struct box {
  int in, out, w, s, v;
  box() {}
  box(int in, int out, int w, int s, int v)
      : in(in), out(out), w(w), s(s), v(v) {}
  void read() { scanf("%d%d%d%d%d", &in, &out, &w, &s, &v); }
};
bool cmp(const box& a, const box& b) { return a.out < b.out; }
bool cmp2(const box& a, const box& b) { return a.in < b.in; }
int n, s;
int dp[maxN][2 * maxN];
box a[maxN];
box b[maxN];
int tk[2 * maxN];
int get(int top, int s) {
  if (s < 0) {
    return 0;
  }
  if (dp[top][s] != -1) {
    return dp[top][s];
  }
  int cleft = a[top].in;
  int cright = a[top].out;
  vector<int> tk(2 * maxN, 0);
  int i = 1;
  for (int ct = 1; ct < 2 * maxN; ++ct) {
    tk[ct] = max(tk[ct], tk[ct - 1]);
    while (i <= n && a[i].out < ct) {
      ++i;
    }
    while (i <= n && a[i].out == ct) {
      if (i == top) {
        ++i;
        continue;
      }
      int curright = a[i].out;
      int curleft = a[i].in;
      if (cleft <= curleft && curright <= cright) {
        int can = min(s - a[i].w, a[i].s);
        int addval = tk[curleft];
        tk[curright] = max(tk[curright], addval + get(i, can));
      }
      ++i;
    }
  }
  return dp[top][s] = tk[2 * maxN - 1] + a[top].v;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d", &n, &s);
  for (int i = 1; i <= n; ++i) {
    a[i].read();
  }
  a[0] = box(-1, 5000, 0, s, 0);
  sort(a + 1, a + n + 1, cmp);
  printf("%d\n", get(0, s));
  return 0;
}
