#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c> n; vll use(n+1, 0); re(i, n-1){ ll a, b;scanf("%lld %lld", &a, &b); G[a].push_back(b); G[b].push_back(a); use[b] = 1; } ll root = -1; for(int i=1;i<=n;i++) { if(!use[i]) { root = i; break; } } f(root, -1); ll s = 0; for(int i=1;i<=n;i++) s += ans[i]; std::cout << s << '\n'; }