#include <bits/stdc++.h>
using namespace std;
struct Query {
  int in, out, w, s, v;
  bool operator<(const Query q) const {
    if (q.in != in) return in < q.in;
    return out > q.out;
  }
} q[512];
int N, S;
int dp[512][1020];
int solve(int a, int b) {
  if (~dp[a][b]) return dp[a][b];
  int ptr = a + 1;
  int tmp[1024];
  memset((tmp), (0), sizeof(tmp));
  tmp[q[a].in] = q[a].v;
  for (int x = q[a].in; x <= q[a].out; x++) {
    if (x) tmp[x] = max(tmp[x], tmp[x - 1]);
    while (ptr < N && q[ptr].in == x) {
      int ns = min(b - q[ptr].w, q[a].s - q[ptr].w);
      if (ns >= 0 && q[ptr].out <= q[a].out)
        tmp[q[ptr].out] = max(tmp[q[ptr].out], tmp[x] + solve(ptr, ns));
      ptr++;
    }
  }
  return dp[a][b] = tmp[q[a].out];
}
int main() {
  scanf("%d%d", &N, &S);
  for (int(i) = 0; (i) < (N); (i)++)
    scanf("%d%d%d%d%d", &q[i].in, &q[i].out, &q[i].w, &q[i].s, &q[i].v);
  q[N].in = 0, q[N].out = 1001, q[N].w = 0, q[N].s = S, q[N].v = 0;
  N++;
  memset((dp), (-1), sizeof(dp));
  sort(q, q + N);
  for (int i = N - 1; i >= 1; i--)
    for (int s = 0; s <= S; s++) solve(i, s);
  printf("%d\n", solve(0, S));
}
