#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void Main() { int N; cin >> N; vector U(N),V(N); vector> G(N); for(int i = 1;i < N;i++) { cin >> U[i] >> V[i]; U[i]--; V[i]--; G[U[i]].push_back(V[i]); G[V[i]].push_back(U[i]); } long long ans = 0; for(int i = 1;i < N;i++) { int a = 0,b = 0; int u = U[i],v = V[i]; for(int nu : G[u]) { if(nu != v) { a++; } } for(int nv : G[v]) { if(nv != u) { b++; } } ans += (long long) a * b; ans++; } for(int i = 0;i < N;i++) { int deg = (int)G[i].size(); ans += (long long)deg * (deg - 1) / 2; } cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; /* cin >> tt; */ while(tt--) Main(); }