#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <iostream>
#define MAXN 200005
#define fr first
#define sc second
#define mp make_pair
using namespace std;
int n,cevap[MAXN];
long long k,dp[MAXN];
priority_queue <long long> q[MAXN];
vector <pair <int,long long> > v[MAXN];
inline void fun(int x)
{
q[x].push(dp[x]);
for(int i=0;i<(int)v[x].size();i++)
{
fun(v[x][i].fr);
if(q[x].size()<q[v[x][i].fr].size()) swap(q[x],q[v[x][i].fr]);
while(!q[v[x][i].fr].empty())
{
q[x].push(q[v[x][i].fr].top());
q[v[x][i].fr].pop();
}
}
while(!q[x].empty() && q[x].top()-dp[x]>k) q[x].pop();
cevap[x]=q[x].size();
}
inline void dfs(int x,long long dep)
{
dp[x]=dep;
for(int i=0;i<(int)v[x].size();i++)
dfs(v[x][i].fr,dep+v[x][i].sc);
}
int main()
{
freopen("runaway.in","r",stdin);
freopen("runaway.out","w",stdout);
scanf("%d %lld",&n,&k);
for(int i=1,a;i<n;i++)
{
long long b;
scanf("%d %lld",&a,&b);
v[a].push_back(mp(i+1,b));
}
dfs(1,0);
fun(1);
for(int i=1;i<=n;i++)
printf("%d\n",cevap[i]);
}
/*
4 5
1 4
2 3
1 5
*/
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNkZWZpbmUgTUFYTiAyMDAwMDUKI2RlZmluZSBmciBmaXJzdAojZGVmaW5lIHNjIHNlY29uZAojZGVmaW5lIG1wIG1ha2VfcGFpcgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbixjZXZhcFtNQVhOXTsKbG9uZyBsb25nIGssZHBbTUFYTl07CnByaW9yaXR5X3F1ZXVlIDxsb25nIGxvbmc+IHFbTUFYTl07CnZlY3RvciA8cGFpciA8aW50LGxvbmcgbG9u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