#include <bits/stdc++.h>
const long long inf = 9223372036854775807ll;
const int iinf = 2147483647;
const int limit = 1048576;
using namespace std;
bool sync_with_stdio(bool sync = false);
struct box {
  int id, in, out, w, s, v;
  box(int id, int in, int out, int w, int s, int v)
      : id{id}, in{in}, out{out}, w{w}, s{s}, v{v} {}
};
int main() {
  int n, S;
  cin >> n >> S;
  vector<vector<box> > boxes(2 * n + 1), expiring_boxes(2 * n + 1);
  for (int i = (int)1; i < (int)n + 1; i++) {
    int in, out, w, s, v;
    cin >> in >> out >> w >> s >> v;
    s = min(s, S);
    box b(i, in, out, w, s, v);
    boxes[out - in].push_back(b);
    expiring_boxes[out].push_back(b);
  }
  box platform(0, 0, 2 * n, 0, S, 0);
  boxes[2 * n].push_back(platform);
  vector<vector<int> > dp(n + 1, vector<int>(S + 1, 0));
  for (auto bb : boxes)
    for (auto b : bb)
      for (int i = (int)0; i < (int)b.s + 1; i++) {
        vector<int> dp_local(b.out + 1, 0);
        for (int j = (int)b.in + 1; j < (int)b.out + 1; j++) {
          dp_local[j] = dp_local[j - 1];
          for (auto p : expiring_boxes[j])
            if (p.in >= b.in and p.w <= i and p.id != b.id)
              dp_local[j] = max(dp_local[j],
                                dp_local[p.in] + dp[p.id][min(i - p.w, p.s)]);
        }
        dp[b.id][i] = dp_local[b.out] + b.v;
      }
  cout << dp[0][S] << "\n";
  return 0;
}
