#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
struct item {
  int in, out;
  int w, s, v;
  item() {}
};
int n, S;
item a[507];
int dp[507][1007];
bool cmp(item a, item b) {
  return a.in < b.in || (a.in == b.in && a.out > b.out);
}
int dfs(int v, int S) {
  if (dp[v][S] != -1) return dp[v][S];
  int result = 0;
  int last_value = 0, right = a[v].in;
  vector<int> value(2 * n + 1, 0);
  for (int i = v + 1; i <= n; i++) {
    if (!(a[v].in <= a[i].in && a[i].out <= a[v].out)) continue;
    if (a[i].w > S) continue;
    while (right <= a[i].in) last_value = max(last_value, value[right++]);
    int val = dfs(i, min(S - a[i].w, a[i].s)) + a[i].v;
    value[a[i].out] = max(value[a[i].out], last_value + val);
    result = max(result, last_value + val);
  }
  return dp[v][S] = result;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> S;
  for (int i = 1; i <= n; i++)
    cin >> a[i].in >> a[i].out >> a[i].w >> a[i].s >> a[i].v;
  a[0].in = 0;
  a[0].out = 2 * n;
  sort(a, a + n + 1, cmp);
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, S);
  return 0;
}
