#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using pii = pair; int main() { int N; cin >> N; vector> g(N); rep(i, N-1) { int u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } auto dfs = [&](auto dfs, int s, int n, vector &seen) { seen.push_back(s); if (n == 3) return; for (int d : g[s]) { if (find(seen.begin(), seen.end(), d) != seen.end()) continue; dfs(dfs, d, n+1, seen); } return; }; set p; rep(i, N) { vector seen; dfs(dfs, i, 0, seen); for (int j : seen) { if (j == i) continue; if (i < j) p.insert({i, j}); else p.insert({j, i}); } } cout << (int)p.size() << endl; return 0; }