#include using namespace std; using ll = long long; int n,m; vector > g[210]; ll u[210]; vector dfs(int ni,int p){ vector dp(m+1,u[ni]); for(auto&itr:g[ni])if(itr.first!=p){ vector nxt = dfs(itr.first,ni); vector dp1(m+1,0); for(int i = 0;i<=m;i++) dp1[i] = dp[i]; for(int i = 0;i<=m;i++){ for(int j = 0;j<=i;j++){ int rest = i - j - 2 * itr.second; if(rest<0) break; dp1[i] = max(dp1[i],max(dp[i],dp[j]+nxt[rest])); } } for(int i = 1;i<=m;i++) dp1[i] = max(dp1[i],dp1[i-1]); swap(dp,dp1); } return dp; } int main(){ cin>>n>>m; for(int i = 0;i>u[i]; for(int i = 1;i>u>>v>>c; g[u].push_back(make_pair(v,c)); g[v].push_back(make_pair(u,c)); } vector ans = dfs(0,-1); cout<