#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
long long n, m, a[100005], b[100005];
long long ee, h[100005], nex[100005 << 1], to[100005 << 1], val[100005 << 1];
long long c1[1000005], c2[1000005];
long long ans[100005];
void addedge(long long x, long long y, long long z) {
  nex[++ee] = h[x];
  to[ee] = y;
  val[ee] = z;
  h[x] = ee;
}
void fix1(long long x, long long v) {
  for (long long i = x; i <= N; i += (i & -i)) c1[i] += v;
}
long long ask1(long long x) {
  long long res = 0;
  for (long long i = x; i >= 1; i -= (i & -i)) res += c1[i];
  return res;
}
void fix2(long long x, long long v) {
  for (long long i = x; i <= N; i += (i & -i)) c2[i] += v;
}
long long ask2(long long x) {
  long long res = 0;
  for (long long i = x; i >= 1; i -= (i & -i)) res += c2[i];
  return res;
}
long long calc(long long m) {
  long long l = 1, r = N, p = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    long long sum = ask2(mid);
    if (sum <= m)
      p = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  long long res = ask1(p) + (m - ask2(p)) * (p + 1);
  return res;
}
void dp(long long x, long long pre, long long dis, long long sum) {
  long long lim = m - 2 * dis;
  if (lim <= 0) return;
  fix1(b[x], a[x] * b[x]), fix2(b[x], a[x]);
  long long l = 0, r = sum, res = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (calc(mid) <= lim)
      res = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  ans[x] = max(ans[x], res);
  for (long long i = h[x]; i; i = nex[i])
    if (to[i] != pre) dp(to[i], x, dis + val[i], sum + a[to[i]]);
  long long mx = 0, del = 0;
  for (long long i = h[x]; i; i = nex[i])
    if (to[i] != pre) {
      if (ans[to[i]] > mx) mx = ans[to[i]], del = to[i];
    }
  for (long long i = h[x]; i; i = nex[i])
    if (to[i] != pre && (to[i] != del || x == 1))
      ans[x] = max(ans[x], ans[to[i]]);
  fix1(b[x], -a[x] * b[x]), fix2(b[x], -a[x]);
}
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; scanf("%lld", a + i), i++)
    ;
  for (long long i = 1; i <= n; scanf("%lld", b + i), i++)
    ;
  for (long long i = 2, x, z; i <= n && scanf("%lld%lld", &x, &z); i++)
    addedge(x, i, z), addedge(i, x, z);
  dp(1, 0, 0, a[1]);
  cout << ans[1] << endl;
  return 0;
}
