import sys input=sys.stdin.buffer.readline n,K=map(int,input().split()) e=[[] for i in range(n)] for _ in range(n-1): a,b,c=map(int,input().split()) a-=1 b-=1 c-=1 e[a]+=[(b,c)] e[b]+=[(a,c)] def CD(e): c=[] g=0 p=[-1]*n v=[0]*n u=[0]*n sq=[(0,n)] for start,W in sq: g+=1 q=[start] while len(q)>0: s=q[-1] if v[s]==0: v[s]=1 for t,_ in e[s]: if v[t]==0 and p[t]==-1: q+=[t] else: u[s]=1+sum(u[t] for t,_ in e[s] if v[t]==0 and p[t]==-1) if all(W-u[t]>=u[t] if v[t]==0 else u[s]>=W-u[s] for t,_ in e[s] if p[t]==-1): nc=s if len(c)