#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector> g(n); for (int i = 0; i < n - 1; ++i) { int x,y; cin >> x >> y; x--; y--; g[x].push_back(y); g[y].push_back(x); } vector> d(4, vector(n)); for (int i = 0; i < n; ++i) { d[0][i] = 1; d[1][i] = g[i].size(); } for (int i = 0; i < n; ++i) { for (int j : g[i]) { d[2][i] += d[1][j] - d[0][i]; } } for (int i = 0; i < n; ++i) { for (int j : g[i]) { d[3][i] += d[2][j] - d[1][i] + 1; } } ll res = 0; for (int i = 0; i < n; ++i) { for (int j = 1; j < 4; ++j) { res += d[j][i]; } } cout << res/2 << endl; }