Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll b = 117;

vector<int> G[100000];
int used[100000];

ll hs[100000];

ll dfs(int n) {
	used[n] = 1;
	ll res = 1;
	for (auto v : G[n]) {
		if (!used[v]) {
			res = (res + dfs(v) * b) % mod;
		}
	}
	return hs[n] = res;
}

int main()
{
	int N;
	cin >> N;
	for (int i = 0, a, b; i < N - 1; i++) {
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	dfs(0);
	sort(hs, hs + N);
	ll res = 0;
	for (int i = 0; i < N; i++) {
		auto p = equal_range(hs, hs + N, hs[i]);
		res += p.second - p.first - 1;
	}
	cout << res / 2 << endl;
	return 0;
}