#include <bits/stdc++.h>
using namespace std;
struct aaa {
  int x, y, w, s, v;
} a[10001];
int n, m, g[2001], f[510][2001];
bool cmp(aaa a, aaa b) {
  if (a.y == b.y) return a.x > b.x;
  return a.y < b.y;
}
int main() {
  int i, j, k, now;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    scanf("%d%d%d%d%d", &a[i].x, &a[i].y, &a[i].w, &a[i].s, &a[i].v);
  sort(a + 1, a + n + 1, cmp);
  a[n + 1].x = 0;
  a[n + 1].y = a[n].y + 1;
  a[n + 1].s = m;
  for (i = 1; i <= n + 1; i++) {
    for (j = a[i].w; j <= m; j++) {
      now = a[i].x;
      g[now] = 0;
      for (k = 1; k < i; k++)
        if (a[k].x >= a[i].x) {
          while (now < a[k].y) now++, g[now] = g[now - 1];
          g[now] = max(g[now], g[a[k].x] + f[k][min(j - a[i].w, a[i].s)]);
        }
      f[i][j] = g[now] + a[i].v;
    }
  }
  printf("%d", f[n + 1][m]);
}
