#include #ifdef LOCAL #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; int main() { int N; cin >> N; vector> E(N - 1); vector D(N); for (int i = 0; i < N - 1; i++) { int u, v; cin >> u >> v; u--; v--; E[i] = make_pair(u, v); D[u]++; D[v]++; } ll ans = 0; for (auto [u, v] : E) ans += (D[u] - 1) * (D[v] - 1); for (int i = 0; i < N; i++) ans += D[i] * (D[i] - 1) / 2; ans += N - 1; cout << ans << endl; }