Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;
 
template<class T>bool chmax(T& a, const T& b) { return (a < b) ? (a = b, 1) : 0; }
template<class T>bool chmin(T& a, const T& b) { return (a > b) ? (a = b, 1) : 0; }
 
using ull=unsigned long long;
const ull B1=1000000003LL;
const ull B2=1000000009LL;
 
const int limit=200010;
ull P1[limit],P2[limit];
 
 
vector<int> tree[100010];
map<ull,int> num;
int sub[100010];
 
int dmax=0;
 
ull dfs(int v,int p){
	ull cur=0;
	for(auto &v2:tree[v]){
		if(v2==p) continue;
		cur+=dfs(v2,v);
	}
 
	//sort(begin(ary),end(ary));
	//for(auto &it:ary) cur=cur*P1[2*get<1>(it)]+get<0>(it);
 
	cur=cur*B1+1;
	//sub[v]+=1;
 
	num[cur]++;	
	return cur;
}
 
int main(void){
	P1[0]=1LL,P2[0]=1LL;
	for(int i=1;i<limit;++i) P1[i]=P1[i-1]*B1,P2[i]=P2[i-1]*B2;
 
 
	int n;
	cin >> n;
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		a--,b--;
		tree[a].push_back(b);
	}
 
	dfs(0,-1);
 
	ull ans=0LL;
	for(auto &it:num){
		//cout << it.second << endl;
		ull cur=it.second;
		ans+=cur*(cur-1)/2LL;
	}
	cout << ans << endl;
	return 0;
}