#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e6 + 5;
vector<pair<int, int> > g[N];
int n;
int x[N], t[N];
long long tree[M << 2], cnt[M << 2];
void update(int i, int l, int r, int a, int v) {
  if (l > a || r < a) return;
  if (l == r) {
    tree[i] += 1ll * v * 1ll * l;
    cnt[i] += v;
    return;
  }
  int mid = (l + r) >> 1;
  update(i << 1, l, mid, a, v);
  update(i << 1 | 1, mid + 1, r, a, v);
  cnt[i] = cnt[i << 1] + cnt[i << 1 | 1];
  tree[i] = tree[i << 1] + tree[i << 1 | 1];
}
long long get(int i, int l, int r, int a, int b, long long k) {
  if (l > b || r < a || !k) return 0;
  if (cnt[i] <= k) return tree[i];
  if (l == r) return min(cnt[i], k) * 1ll * l;
  int mid = (l + r) >> 1;
  if (cnt[i << 1] > k) return get(i << 1, l, mid, a, b, k);
  return get(i << 1 | 1, mid + 1, r, a, b, k - cnt[i << 1]) + tree[i << 1];
}
long long T;
pair<long long, long long> dfs(int node, long long cur) {
  pair<long long, long long> ret = {0, 0};
  if (2 * cur > T) return ret;
  update(1, 1, 1e6, t[node], x[node]);
  long long s = 0, e = cnt[1], ans = 0;
  while (s <= e) {
    long long mid = (s + e) >> 1;
    if (get(1, 1, 1e6, 1, 1e6, mid) + 2 * cur <= T)
      ans = mid, s = mid + 1;
    else
      e = mid - 1;
  }
  ret.first = ret.second = ans;
  for (int i = 0; i < g[node].size(); i++) {
    auto temp = dfs(g[node][i].first, cur + g[node][i].second);
    if (temp.second > ret.second) ret.second = temp.second;
    if (ret.second > ret.first) swap(ret.first, ret.second);
  }
  update(1, 1, 1e6, t[node], -x[node]);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> T;
  for (int i = 1; i <= n; i++) cin >> x[i];
  for (int i = 1; i <= n; i++) cin >> t[i];
  for (int i = 2, p, l; i <= n; i++) {
    cin >> p >> l;
    g[p].push_back({i, l});
  }
  cout << dfs(1, 0).first << '\n';
  return 0;
}
