#include <bits/stdc++.h>
using namespace std;
struct TBox {
  int in, out, w, s, v;
  int id;
  TBox(int in = 0, int out = 0, int w = 0, int s = 0, int v = 0, int id = 0)
      : in(in), out(out), w(w), s(s), v(v), id(id) {}
};
TBox allb[1000];
vector<TBox> byFin[2000];
int dp[1001][1001];
int mem[1001][1001];
int getDp(int id, int S) {
  if (S < 0) return -1e9;
  if (dp[id][S] != -1) return dp[id][S];
  int &res = dp[id][S];
  TBox &b = allb[id];
  mem[id][b.in] = 0;
  for (int t = b.in + 1; t <= b.out; ++t) {
    mem[id][t] = mem[id][t - 1];
    for (TBox &bb : byFin[t]) {
      if (bb.id == b.id) continue;
      if (bb.in < b.in) continue;
      int res = mem[id][bb.in] + bb.v + getDp(bb.id, min(S - bb.w, bb.s));
      mem[id][t] = max(mem[id][t], res);
    }
  }
  return res = mem[id][b.out];
}
int main() {
  ios::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  int N, S;
  cin >> N >> S;
  allb[0] = TBox(0, 2 * N, 0, S, 0, 0);
  byFin[2 * N].push_back(allb[0]);
  for (int i = 0; i < (int)(1001); ++i)
    for (int j = 0; j < (int)(1001); ++j) dp[i][j] = -1;
  for (int i = 0; i < (int)(N); ++i) {
    TBox &b = allb[i + 1];
    b.id = i + 1;
    cin >> b.in >> b.out >> b.w >> b.s >> b.v;
    byFin[b.out].push_back(b);
  }
  cout << getDp(0, S) << '\n';
  return 0;
}
