#include <bits/stdc++.h>
using namespace std;
int N, S;
vector<pair<pair<int, int>, pair<pair<int, int>, int> > > in;
int lo[510], hi[510], w[510], s[510], v[510];
int dp[510][1010];
int rdp[510];
int endp[510];
int relax(int fr, int to, int w) {
  fill(rdp + fr, rdp + N + 1, 0);
  for (int i = N - 1; i >= fr; --i) {
    rdp[i] = rdp[i + 1];
    if (to >= hi[i]) (rdp[i]) = max((rdp[i]), (dp[i][w] + rdp[endp[i]]));
  }
  return rdp[fr];
}
int main() {
  scanf("%d%d", &N, &S);
  in.resize(N);
  for (int i = 0; i < N; ++i)
    scanf("%d%d%d%d%d", &in[i].first.first, &in[i].first.second,
          &in[i].second.first.first, &in[i].second.first.second,
          &in[i].second.second),
        in[i].first.second *= -1;
  sort(in.begin(), in.end());
  for (int i = 0; i < N; ++i)
    lo[i] = in[i].first.first, hi[i] = -in[i].first.second,
    w[i] = in[i].second.first.first, s[i] = in[i].second.first.second,
    v[i] = in[i].second.second;
  for (int i = 0; i < N; ++i) endp[i] = lower_bound(lo, lo + N, hi[i]) - lo;
  for (int i = 0; i <= S; ++i)
    if (w[N - 1] <= i)
      dp[N - 1][i] = v[N - 1];
    else
      dp[N - 1][i] = 0;
  for (int p = N - 2; p >= 0; --p) {
    for (int i = 0; i <= S; ++i) {
      if (i - w[p] < 0) continue;
      dp[p][i] = relax(p + 1, hi[p], min(i - w[p], s[p])) + v[p];
    }
  }
  printf("%d\n", relax(0, 2 * N + 1, S));
  return 0;
}
