#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, ch = getchar(), f = 0;
  while (!isdigit(ch)) {
    f = ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return f ? -x : x;
}
int n, S, s[510], v[510], a[510], b[510], w[510], m = 0, f[1010][1010];
int F(int K, int S) {
  if (f[K][S] != -1) return f[K][S];
  int tmp = 0, tot = 0;
  int *p = new int[n + 1];
  for (register int i = 1; i <= n; i++)
    if (i != K && a[i] >= a[K] && b[i] <= b[K]) p[++tot] = i;
  if (tot == 0) {
    delete p;
    return f[K][S] = v[K];
  }
  int *d = new int[1010];
  memset(d, 0, sizeof(d));
  int ans = 0;
  for (register int k = a[K], i = 1; i <= tot; i++) {
    while (k < b[p[i]]) d[k++] = ans;
    if (S < w[p[i]]) continue;
    if (a[p[i]] != 0)
      ans = d[b[p[i]]] =
          max(ans, d[a[p[i]]] + F(p[i], min(s[p[i]], S - w[p[i]])));
    else
      ans = d[b[p[i]]] = max(ans, F(p[i], min(s[p[i]], S - w[p[i]])));
  }
  delete d;
  delete p;
  return f[K][S] = ans + v[K];
}
int main() {
  n = read(), S = read();
  for (register int i = 1; i <= n; i++)
    a[i] = read(), b[i] = read(), m = max(m, b[i]), w[i] = read(),
    s[i] = read(), v[i] = read();
  for (register int i = 1; i < n; i++)
    for (register int j = i; j <= n; j++)
      if (b[i] > b[j] || b[i] == b[j] && a[i] < a[j]) {
        swap(a[i], a[j]);
        swap(b[i], b[j]);
        swap(w[i], w[j]);
        swap(s[i], s[j]);
        swap(v[i], v[j]);
      }
  a[n + 1] = 0, b[n + 1] = b[n], s[n + 1] = S;
  memset(f, -1, sizeof(f));
  printf("%d", F(n + 1, S));
}
