#include <bits/stdc++.h>
using namespace std;
vector<int> g[2005];
int dp[507][1007];
int n, S;
int in[505], out[505], s[505], w[505], v[505];
int solve(int id, int S) {
  if (dp[id][S] == -1) {
    vector<int> d;
    for (int i = in[id]; i <= out[id]; ++i) d.push_back(0);
    for (int i = in[id]; i < out[id]; ++i) {
      int cur = i - in[id];
      d[cur + 1] = max(d[cur + 1], d[cur]);
      for (int j = 0; j < g[i].size(); ++j) {
        int to = g[i][j];
        if (to != id && out[to] <= out[id] && w[to] <= S) {
          int cur_out = out[to] - in[id];
          d[cur_out] = max(d[cur_out],
                           d[cur] + solve(to, min(S - w[to], s[to])) + v[to]);
        }
      }
    }
    int tmp = d[out[id] - in[id]];
    dp[id][S] = tmp;
  }
  return dp[id][S];
}
int main() {
  scanf("%d%d", &n, &S);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d%d%d", &in[i], &out[i], &w[i], &s[i], &v[i]);
    g[in[i]].push_back(i);
  }
  for (int i = 0; i < n + 5; ++i)
    for (int j = 0; j < S + 2; ++j) dp[i][j] = -1;
  in[0] = 0, out[0] = 2 * n + 1;
  printf("%d\n", solve(0, S));
  return 0;
}
