#include <bits/stdc++.h>
using namespace std;
const int N = 1024;
const int INF = 1e9 + 9;
struct elem {
  int w, s, c;
  int l, r;
  elem() {}
} a[N];
int n, second;
int d[N][N], td[N];
vector<int> v[N];
bool operator<(const elem &x, const elem &y) {
  return (x.r - x.l != y.r - y.l) ? (x.r - x.l < y.r - y.l) : (x.l < y.l);
}
void Calc_dp() {
  for (int i = int(1); i <= int(n); ++i) {
    for (int spc = int(0); spc <= int(a[i].s); ++spc) {
      for (int k = int(a[i].l); k <= int(a[i].r); ++k) {
        td[k] = (k == a[i].l ? 0 : td[k - 1]);
        for (auto son : v[k]) {
          if (a[son].l < a[i].l || spc < a[son].w || i == son) continue;
          td[k] =
              max(td[k], td[a[son].l] + d[son][min(spc - a[son].w, a[son].s)]);
        }
      }
      d[i][spc] = a[i].c + td[a[i].r];
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> second;
  for (int i = int(1); i <= int(n); ++i)
    cin >> a[i].l >> a[i].r >> a[i].w >> a[i].s >> a[i].c;
  ++n;
  a[n].l = 0, a[n].r = 2 * n;
  a[n].s = second, a[n].c = 0;
  sort(a + 1, a + 1 + n);
  for (int i = int(1); i <= int(n); ++i) v[a[i].r].push_back(i);
  Calc_dp();
  cout << d[n][second] << "\n";
  return 0;
}
