#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; typedef pair P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} int main(){ int n; cin >> n; vector> G(n); vector> E; rep(i, n - 1){ int u, v; cin >> u >> v; u--; v--; G[u].push_back(v); G[v].push_back(u); E.emplace_back(u, v); } vector a(3); a[0] = n - 1; for(auto [u, v] : E){ long long cu = G[u].size() - 1; long long cv = G[v].size() - 1; a[1] += cu; a[1] += cv; } a[1] /= 2; for(auto [u, v] : E){ long long cu = G[u].size() - 1; long long cv = G[v].size() - 1; a[2] += cu * cv; } cout << a; long long ans = a[0] + a[1] + a[2]; cout << ans << "\n"; return 0; }