#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n, T;
long long x[N], t[N], bit[2][N], f[N], best[N], ans[N];
vector<pair<long long, long long> > g[N];
void update(long long i, long long idx, long long k) {
  while (idx < N) {
    bit[i][idx] += k;
    idx += idx & -idx;
  }
}
long long pref(long long i, long long idx) {
  long long ans = 0;
  while (idx > 0) {
    ans += bit[i][idx];
    idx -= idx & -idx;
  }
  return ans;
}
long long check(long long y, long long remT) {
  long long timeReqd = pref(0, y);
  return timeReqd <= remT;
}
long long binsearch(long long lo, long long hi, long long remT) {
  while (lo < hi) {
    long long mid = (lo + hi + 1) / 2;
    if (check(mid, remT))
      lo = mid;
    else
      hi = mid - 1;
  }
  return lo;
}
long long work(long long remT) {
  long long lastT = binsearch(0, 1e6, remT);
  long long cookies = pref(1, lastT);
  if (lastT < 1e6) {
    long long canHave =
        min(f[lastT + 1], (remT - pref(0, lastT)) / (lastT + 1));
    cookies += canHave;
  }
  return cookies;
}
void dfs(long long k, long long par, long long remT) {
  update(0, t[k], t[k] * x[k]);
  update(1, t[k], x[k]);
  f[t[k]] += x[k];
  best[k] = work(remT);
  ans[k] = best[k];
  for (auto &it : g[k]) {
    if (it.first == par) continue;
    dfs(it.first, k, remT - it.second * 2);
  }
  f[t[k]] -= x[k];
  update(0, t[k], -t[k] * x[k]);
  update(1, t[k], -x[k]);
}
long long dfs2(long long k, long long par) {
  vector<long long> v;
  for (auto &it : g[k]) {
    if (it.first == par) continue;
    v.push_back(dfs2(it.first, k));
  }
  sort(v.rbegin(), v.rend());
  if (k == 1)
    ans[k] = max(best[k], v[0]);
  else {
    ans[k] = best[k];
    if (v.size() >= 2) ans[k] = max(ans[k], v[1]);
  }
  return ans[k];
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> T;
  for (long long i = 1; i <= n; i++) cin >> x[i];
  for (long long i = 1; i <= n; i++) cin >> t[i];
  for (long long i = 2; i <= n; i++) {
    long long p, l;
    cin >> p >> l;
    g[p].push_back({i, l});
  }
  dfs(1, 1, T);
  dfs2(1, 1);
  cout << ans[1];
  return 0;
}
