Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <map>
#include <vector>
#include <iostream>
using namespace std;
typedef unsigned long long ull;
const ull base = 1000000007;
int n, a, b; vector<vector<int> > G; map<ull, int> cnt;
ull solve(int pos, int pre) {
	ull ret = 1;
	for (int i : G[pos]) {
		if (i == pre) continue;
		ret += solve(i, pos) * base;
	}
	cnt[ret]++;
	return ret;
}
int main() {
	cin >> n; G.resize(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b; a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	solve(0, -1);
	ull ret = 0;
	for (pair<ull, int> i : cnt) ret += 1ULL * i.second * (i.second - 1) / 2;
	cout << ret << endl;
	return 0;
}