#include <bits/stdc++.h>
#define int long long
#define mp make_pair
using namespace std;
typedef pair<int, long long> PII;
main(){
freopen("runaway.in", "r", stdin);
freopen("runaway.out", "w", stdout);
int N; cin >> N; long long L; cin >> L;
PII prevnode[N+1];
PII jump[N+1][20];
vector<int> graph[N+1];
prevnode[0] = mp(0, 0);
map<int, int> marked;
int dp[N+1];
for (int i = 2; i <= N; i++){
int p; long long l; scanf("%d %I64d", &p, &l); graph[p].push_back(i);
prevnode[i] = mp(p, l);
}
jump[0][0] = mp(0, 0);
for (int i = 1; i <= N; i++){
jump[i][0] = prevnode[i];
}
for (int i = 1; i <= N; i++){
for (int j = 1; j < 20; j++){
jump[i][j] = mp(jump[(jump[i][j-1].first)][j-1].first, jump[i][j-1].second + jump[(jump[i][j-1].first)][j-1].second);
}
}
for (int i = 1; i <= N; i++){
long long temp = L;
int node = i;
for (int j = 19; j >= 0; j--){
if (jump[node][j].second <= temp && (jump[node][j].first)){
temp -= jump[node][j].second;
node = jump[node][j].first;
}
}
marked[prevnode[node].first]++;
}
memset(dp, 0, sizeof(dp));
for (int i = N; i >= 1; i--){
for (int k: graph[i]){
dp[i] += dp[k];
}
dp[i]++;
dp[i] -= marked[i];
}
for (int i = 1; i <= N; i++){
printf("%I64d\n", dp[i]);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIG1wIG1ha2VfcGFpcgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0eXBlZGVmIHBhaXI8aW50LCBsb25nIGxvbmc+IFBJSTsKbWFpbigpewogICAgZnJlb3BlbigicnVuYXdheS5pbiIsICJyIiwgc3RkaW4pOwogICAgZnJlb3BlbigicnVuYXdheS5vdXQiLCAidyIsIHN0ZG91dCk7CiAgICBpbnQgTjsgY2luID4+IE47IGxvbmcgbG9uZyBMOyBjaW4gPj4gTDsKICAgIFBJSSBwcmV2bm9kZVtOKzFdOwogICAgUElJIGp1bXBbTisxXVsyMF07CiAgICB2ZWN0b3I8aW50PiBncmFwaFtOKzFdOwogICAgcHJldm5vZGVbMF0gPSBtcCgwLCAwKTsKICAgIG1hcDxpbnQsIGludD4gbWFya2VkOwogICAgaW50IGRwW04rMV07CiAgICBmb3IgKGludCBpID0gMjsgaSA8PSBOOyBpKyspewogICAgICAgIGludCBwOyBsb25nIGxvbmcgbDsgc2NhbmYoIiVkICVJNjRkIiwgJnAsICZsKTsgZ3JhcGhbcF0ucHVzaF9iYWNrKGkpOwogICAgICAgIHByZXZub2RlW2ldID0gbXAocCwgbCk7CiAgICB9CiAgICBqdW1wWzBdWzBdID0gbXAoMCwgMCk7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBOOyBpKyspewogICAgICAgIGp1bXBbaV1bMF0gPSBwcmV2bm9kZVtpXTsKICAgIH0KICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IE47IGkrKyl7CiAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPCAyMDsgaisrKXsKICAgICAgICAgICAganVtcFtpXVtqXSA9IG1wKGp1bXBbKGp1bXBbaV1bai0xXS5maXJzdCldW2otMV0uZmlyc3QsIGp1bXBbaV1bai0xXS5zZWNvbmQgKyBqdW1wWyhqdW1wW2ldW2otMV0uZmlyc3QpXVtqLTFdLnNlY29uZCk7CiAgICAgICAgfQogICAgfQoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IE47IGkrKyl7CiAgICAgICAgbG9uZyBsb25nIHRlbXAgPSBMOwogICAgICAgIGludCBub2RlID0gaTsKICAgICAgICBmb3IgKGludCBqID0gMTk7IGogPj0gMDsgai0tKXsKICAgICAgICAgICAgaWYgKGp1bXBbbm9kZV1bal0uc2Vjb25kIDw9IHRlbXAgJiYgKGp1bXBbbm9kZV1bal0uZmlyc3QpKXsKICAgICAgICAgICAgICAgIHRlbXAgLT0ganVtcFtub2RlXVtqXS5zZWNvbmQ7CiAgICAgICAgICAgICAgICBub2RlID0ganVtcFtub2RlXVtqXS5maXJzdDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBtYXJrZWRbcHJldm5vZGVbbm9kZV0uZmlyc3RdKys7CiAgICB9CiAgICBtZW1zZXQoZHAsIDAsIHNpemVvZihkcCkpOwogICAgZm9yIChpbnQgaSA9IE47IGkgPj0gMTsgaS0tKXsKICAgICAgICBmb3IgKGludCBrOiBncmFwaFtpXSl7CiAgICAgICAgICAgIGRwW2ldICs9IGRwW2tdOwogICAgICAgIH0KICAgICAgICBkcFtpXSsrOwogICAgICAgIGRwW2ldIC09IG1hcmtlZFtpXTsKICAgIH0KICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IE47IGkrKyl7CiAgICAgICAgcHJpbnRmKCIlSTY0ZFxuIiwgZHBbaV0pOwogICAgfQogICAgcmV0dXJuIDA7Cgp9Cg==