#include <bits/stdc++.h>
using namespace std;
const char DEBUG = 0;
const int Q = 1 << 20;
mt19937 gen(
    (unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
#pragma comment(linker, "/STACK:16777216")
struct edge {
  int v, t;
};
struct pp {
  long long total_t;
  long long cnt;
};
vector<edge> g[100000];
long long cnt[100000];
long long need_t[100000];
long long ost_t[100000];
pp tr[2 * Q];
long long dp[100000];
long long have;
void add(int i) {
  int v = need_t[i] + Q;
  tr[v].cnt += cnt[i];
  tr[v].total_t += cnt[i] * need_t[i];
  long long sum = 1LL * cnt[i] * need_t[i];
  for (v /= 2; v; v /= 2) {
    tr[v].total_t += sum;
    tr[v].cnt += cnt[i];
  }
}
void erase(int i) {
  int v = need_t[i] + Q;
  long long sum = 1LL * cnt[i] * need_t[i];
  tr[v].cnt -= cnt[i];
  tr[v].total_t -= sum;
  for (v /= 2; v; v /= 2) {
    tr[v].total_t -= sum;
    tr[v].cnt -= cnt[i];
  }
}
long long calc(long long t) {
  int v = 1;
  long long res = 0;
  while (v < Q) {
    if (t >= tr[2 * v].total_t) {
      res += tr[2 * v].cnt;
      t -= tr[2 * v].total_t;
      v = 2 * v + 1;
    } else
      v *= 2;
  }
  res += min(t / (v - Q), tr[v].cnt);
  return res;
}
void dfs(int v, long long cur_t = have) {
  if (cur_t < 0) return;
  add(v);
  dp[v] = calc(cur_t);
  long long m1 = 0, m2 = 0;
  for (edge e : g[v]) {
    dfs(e.v, cur_t - 2 * e.t);
    if (dp[e.v] > m1)
      m2 = m1, m1 = dp[e.v];
    else
      m2 = max(m2, dp[e.v]);
  }
  erase(v);
  if (!v)
    dp[v] = max(dp[v], m1);
  else
    dp[v] = max(dp[v], m2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n >> have;
  for (int i = 0; i < n; i++) cin >> cnt[i];
  for (int i = 0; i < n; i++) cin >> need_t[i];
  for (int i = 1; i < n; i++) {
    int p, t;
    cin >> p >> t;
    g[--p].push_back({i, t});
  }
  dfs(0);
  cout << dp[0];
  return 0;
}
