#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD998 = 998244353;
const int INF = 1e9;
const long long LLINF = 1e18;
mt19937_64 rng(
    (unsigned int)chrono::steady_clock::now().time_since_epoch().count());
template <class T>
T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
struct edge {
  int to, cost;
  edge() {}
  edge(int to, int cost) : to(to), cost(cost) {}
};
vector<vector<edge>> graph;
vector<int> cookies;
vector<int> asdas8d;
const int MAXTIME = 1e6 + 20;
struct Fenwick {
  long long tree[MAXTIME];
  void inc(int at, long long delta) {
    for (; at < MAXTIME; at |= (at + 1)) {
      tree[at] += delta;
    }
  }
  long long pref(int r) {
    long long ans = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) {
      ans += tree[r];
    }
    return ans;
  }
  int lower_bound(long long x) {
    int pos = 0;
    for (int blockSize = 1 << (31 - __builtin_clz(MAXTIME)); blockSize != 0;
         blockSize >>= 1) {
      int p = pos + blockSize - 1;
      if (p < MAXTIME && tree[p] <= x) {
        x -= tree[p];
        pos += blockSize;
      }
    }
    return pos - 1;
  }
} overall, ccs;
long long T;
int dfs(int u = 0, long long up = 0) {
  overall.inc(asdas8d[u], 1LL * asdas8d[u] * cookies[u]);
  ccs.inc(asdas8d[u], cookies[u]);
  long long left = T - up - up;
  int i = overall.lower_bound(left);
  long long took = overall.pref(i);
  int ans = ccs.pref(i);
  if (0 < i + 1 && i + 1 < MAXTIME) {
    ans += (left - took) / (i + 1);
  }
  int mx = 0, mx2 = 0;
  for (auto [v, cost] : graph[u]) {
    int res = dfs(v, up + cost);
    if (res >= mx) {
      mx2 = mx;
      mx = res;
    } else if (res > mx2) {
      mx2 = res;
    }
  }
  overall.inc(asdas8d[u], -1LL * asdas8d[u] * cookies[u]);
  ccs.inc(asdas8d[u], -cookies[u]);
  return max(ans, u == 0 ? mx : mx2);
}
void run() {
  int n;
  cin >> n >> T;
  cookies.resize(n);
  for (int &x : cookies) {
    cin >> x;
  }
  asdas8d.resize(n);
  for (int &x : asdas8d) {
    cin >> x;
  }
  graph.resize(n);
  for (int i = 1; i < n; i++) {
    int p, cost;
    cin >> p >> cost;
    graph[p - 1].emplace_back(i, cost);
  }
  cout << dfs() << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int tests = 1;
  while (tests--) {
    run();
  }
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  return 0;
}
