#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int powmod(int a, int b) {
  int tmp = 1;
  a %= (1000000007);
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a % (1000000007);
    a = a * a % (1000000007);
  }
  return tmp;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T>
inline void R(T &xx) {
  xx = 0;
  char ch = getchar();
  bool F = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') F = 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
  if (F) xx = -xx;
}
template <class T>
inline void add(int &x, T y) {
  for (x += y; x >= (1000000007); x -= (1000000007))
    ;
}
struct nod {
  int in, ou, w, s, v;
  inline bool operator<(const nod &b) const {
    return ou == b.ou ? in > b.in : (ou < b.ou);
  }
} a[5011];
int f[5011][5011], n, S, g[5011];
int main() {
  R(n);
  R(S);
  a[0] = (nod){0, 2 * n, 0, S, 0};
  for (int i = 1; i <= n; i++)
    R(a[i].in), R(a[i].ou), R(a[i].w), R(a[i].s), R(a[i].v);
  sort(a, a + (++n));
  for (int i = 0; i < (int)n; i++)
    for (int k = a[i].w; k <= S; k++) {
      int rem = min(k - a[i].w, a[i].s), nw = a[i].in;
      g[nw] = 0;
      for (int j = 0; j < (int)i; j++)
        if (a[j].in >= a[i].in) {
          while (nw < a[j].ou) g[++nw] = g[nw - 1];
          g[nw] = max(g[nw], g[a[j].in] + f[j][rem]);
        }
      f[i][k] = g[nw] + a[i].v;
    }
  printf("%d\n", f[n - 1][S]);
  return 0;
}
