#include <bits/stdc++.h>
using namespace std;
int n;
int s;
struct st {
  int in;
  int outt;
  int w;
  int s;
  int v;
  st(bool f = false) {
    if (f == false) scanf("%d %d %d %d %d", &in, &outt, &w, &s, &v);
  }
};
vector<st> v;
long long int dp[502][1002];
bool use[502][1002];
vector<int> ins[502];
vector<long long int> im[502];
inline long long int dfs(int a, int b) {
  if (use[a][b]) {
    return dp[a][b];
  }
  use[a][b] = true;
  int siz = v.size();
  long long int f;
  im[a].clear();
  ins[a].clear();
  ins[a].push_back(-1);
  im[a].push_back(v[a].v);
  long long int cur = v[a].v;
  for (int i = 0; i < siz; i++) {
    if (i == a) {
      continue;
    }
    if (v[a].in <= v[i].in && v[i].outt <= v[a].outt) {
      int a_a = i;
      int b_b = b - v[i].w;
      if (b_b > v[i].s) {
        b_b = v[i].s;
      }
      if (b_b < 0) {
        continue;
      }
      f = dfs(a_a, b_b);
      int ind =
          upper_bound(ins[a].begin(), ins[a].end(), v[i].in) - ins[a].begin();
      ind--;
      f += im[a][ind];
      if (cur < f) {
        cur = f;
      }
      im[a].push_back(cur);
      ins[a].push_back(v[i].outt);
    }
  }
  dp[a][b] = cur;
  return dp[a][b];
}
bool cmp(st &a, st &b) { return a.outt < b.outt; }
int main() {
  scanf("%d%d", &n, &s);
  int mint = INT_MAX;
  int maxt = -1;
  for (int i = 0; i < n; i++) {
    v.push_back(st());
    mint = min(mint, v.back().in);
    maxt = max(maxt, v.back().outt);
  }
  maxt++;
  v.push_back(st(true));
  v.back().in = mint;
  v.back().outt = maxt;
  v.back().s = s;
  v.back().v = 0;
  v.back().w = 0;
  sort(v.begin(), v.begin() + v.size() - 1, cmp);
  int ans = dfs(v.size() - 1, v.back().s);
  printf("%d\n", ans);
  return 0;
}
