#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
ll a[100001], b[100001], c[100001], n, k;
vector<ll> g[100001];
pii t[1000001 * 4];
ll query(ll x, ll tl = 0, ll tr = 1000001, ll i = 1) {
  if (tl == tr) return x / tr;
  ll m = (tl + tr) / 2;
  if (x <= t[i * 2].first) return query(x, tl, m, i * 2);
  return t[i * 2].second + query(min(x - t[i * 2].first, t[i * 2 + 1].first),
                                 m + 1, tr, i * 2 + 1);
}
void update(ll p, ll x, ll tl = 0, ll tr = 1000001, ll i = 1) {
  if (tl == tr)
    t[i].first += p * x, t[i].second += x;
  else {
    ll m = (tl + tr) / 2;
    if (p <= m)
      update(p, x, tl, m, i * 2);
    else
      update(p, x, m + 1, tr, i * 2 + 1);
    t[i].first = t[i * 2].first + t[i * 2 + 1].first;
    t[i].second = t[i * 2].second + t[i * 2 + 1].second;
  }
}
ll dfs(ll i) {
  if (k <= 0) return 0;
  k -= c[i] * 2;
  update(a[i], b[i]);
  ll m1 = 0, m2 = 0, m3 = k > 0 ? query(k) : k;
  for (ll j : g[i]) {
    ll y = dfs(j);
    if (y > m1)
      m2 = m1, m1 = y;
    else if (y > m2)
      m2 = y;
  }
  update(a[i], -b[i]);
  k += c[i] * 2;
  return max(i ? m2 : m1, m3);
}
int main() {
  scanf("%lld%lld", &n, &k);
  for (ll i = 0; i < n; i++) scanf("%lld", b + i);
  for (ll i = 0; i < n; i++) scanf("%lld", a + i);
  for (ll i = 1, x; i < n; i++)
    scanf("%lld%lld", &x, c + i), g[x - 1].push_back(i);
  printf("%lld\n", dfs(0));
}
