#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector> Edges(n - 1); vector deg(n, 0); rep(i, n - 1) { int a, b; cin >> a >> b; --a, --b; Edges[i] = { a, b }; deg[a]++, deg[b]++; } ll ans = 0; ans += n - 1; rep(i, n) ans += deg[i] * (deg[i] - 1) / 2; rep(i, n - 1) { auto [a, b] = Edges[i]; ans += (deg[a] - 1) * (deg[b] - 1); } cout << ans << endl; return 0; }