#include #include #include using namespace std; int main() { int N; cin >> N; vector> edge(N); for (int i = 0; i < N - 1; ++i) { int u, v; cin >> u >> v; u--; v--; edge[u].push_back(v); edge[v].push_back(u); } int ans = 0; deque nxt; vector used(N, false); used[0] = true; nxt.push_back(0); while (!nxt.empty()) { int pos = nxt.back(); nxt.pop_back(); for (int to : edge[pos]) { ans++; for (int nt : edge[to]) { if (nt != pos) ans += edge[nt].size(); } if (!used[to]) { nxt.push_back(to); used[to] = true; } } } cout << ans / 2 << endl; return 0; }