#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define REPR(i, n) for(ll i = n;i >= 0;i--) #define FOR(i, m, n) for(ll i = m;i < n;i++) #define FORR(i, m, n) for(ll i = m;i >= n;i--) #define REPO(i, n) for(ll i = 1;i <= n;i++) #define ll long long #define INF (ll)1ll << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(),n.end() #define MOD (ll)1000000007 vector g[300010]; int ans; int sz[300010], par[300010], a[300010], b[300010]; ll c[300010], cv[300010], co[300010]; void dfs(int v, int p){ sz[v] = 1; for(auto nv : g[v]){ if(nv == p)continue; dfs(nv, v); sz[v] += sz[nv]; par[nv] = v; } } int main(){ ll N, Q; cin >> N >> Q; REP(i, N - 1){ cin >> a[i] >> b[i]; a[i]--;b[i]--; g[a[i]].push_back(b[i]); g[b[i]].push_back(a[i]); cin >> cv[i]; } ans = N; dfs(0, -1); REP(i, N - 1){ if(par[a[i]] == b[i])co[a[i]] = c[a[i]] = cv[i]; else co[b[i]] = c[b[i]] = cv[i]; } REP(i, Q){ ll t; cin >> t; if(t == 1){ ll v, x; cin >> v >> x; v--; int nowv = v; while(nowv != 0){ c[nowv] -= x; if(c[nowv] <= 0){ ans -= sz[nowv]; int nev = par[nowv]; while(nev != 0){ sz[nev] -= sz[nowv]; c[nev] += co[nowv] - (c[nowv] + x); nev = par[nev]; } break; } nowv = par[nowv]; } } else{ cout << ans << endl; } } }