#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node{
int x,y,next;
}a[210000];int len,last[210000];
struct president_tree{
int lc,rc;
ll sum,c;
}t[30*110000];int cnt,rt[110000];
void ins(int x,int y)
{
len++;
a[len].x=x;a[len].y=y;
a[len].next=last[x];last[x]=len;
}
int id,l[110000],r[110000];
void Link(int &u,int l,int r,int p,int c)
{
if(!u)u=++cnt;
t[u].c++;t[u].sum+=c;
if(l==r)return ;
int mid=(l+r)/2;
if(p<=mid)Link(t[u].lc,l,mid,p,c);
else Link(t[u].rc,mid+1,r,p,c);
}
void Merge(int &u1,int u2)
{
if(!u1||!u2){u1=u1+u2;return ;}
t[u1].c+=t[u2].c;t[u1].sum+=t[u2].sum;
Merge(t[u1].lc,t[u2].lc);
Merge(t[u1].rc,t[u2].rc);
}
ll c[110000],d[110000];
ll query(int u1,int u2,int l,int r,ll s)
{
if(l==r)return min(t[u2].c-t[u1].c,s/l);
ll cc=t[t[u2].lc].sum-t[t[u1].lc].sum;
ll k=t[t[u2].lc].c-t[t[u1].lc].c;
int mid=(l+r)/2;
if(cc>s)return query(t[u1].lc,t[u2].lc,l,mid,s);
else return k+query(t[u1].rc,t[u2].rc,mid+1,r,s-cc);
}
void dfs(int x,int fa)
{
l[x]=++id;
for(int k=last[x];k;k=a[k].next)
{
int y=a[k].y;
if(y!=fa)
dfs(y,x);
}
r[x]=id;
}
int n,m;
int main()
{
scanf("%d%d",&n,&m);
len=0;memset(last,0,sizeof(last));
for(int i=1;i<=n;i++)
{
int x;
scanf("%d%lld%lld",&x,&c[i],&d[i]);
ins(i,x),ins(x,i);
}
id=0;dfs(1,0);
for(int i=1;i<=n;i++)Link(rt[l[i]],1,1000000000,c[i],c[i]);
for(int i=1;i<=n;i++)Merge(rt[i],rt[i-1]);
ll ans=0;
for(int i=1;i<=n;i++)
{
ll sum=query(rt[l[i]-1],rt[r[i]],1,1000000000,m);
ans=max(ans,d[i]*sum);
}
printf("%lld\n",ans);
return 0;
}