#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 = 0;i < N;i++) { int deg = (int)G[i].size(); ans += (long long)deg * (deg - 1) ; for(int j : G[i]) { ans += (long long)(deg - 1) * ((int)G[j].size() - 1); } } ans /= 2; ans += N - 1; cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; /* cin >> tt; */ while(tt--) Main(); }