#include <bits/stdc++.h>
using namespace std;
template <typename G1, typename G2 = G1, typename G3 = G1>
struct triple {
  G1 first;
  G2 second;
  G3 T;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, b;
  cin >> n >> b;
  vector<int> c(n), d(n);
  vector<vector<int>> g(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> d[i];
    if (i > 0) {
      int x;
      cin >> x;
      g[x - 1].push_back(i);
    }
  }
  const int oo = b + 1;
  vector<vector<int>> dp1(n, vector<int>(n + 1, oo));
  vector<vector<int>> dp2(n, vector<int>(n + 1, oo));
  vector<int> s(n);
  for (int i = n - 1; i >= 0; i--) {
    s[i] = 1;
    dp1[i][0] = 0;
    dp1[i][1] = c[i];
    dp2[i][1] = c[i] - d[i];
    for (auto v : g[i]) {
      for (int j = s[i]; j >= 0; j--)
        for (int k = 0; k <= s[v]; k++) {
          dp1[i][j + k] = min(dp1[i][j + k], dp1[i][j] + dp1[v][k]);
          dp2[i][j + k] =
              min(dp2[i][j + k], dp2[i][j] + min(dp1[v][k], dp2[v][k]));
        }
      s[i] += s[v];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (min(dp1[0][i], dp2[0][i]) <= b) ans = i;
  cout << ans << '\n';
  return 0;
}
