Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int N;
vector<int>G[1<<17];
map<long,int>M;
long B1=1000000181,B2=1000999943;
long ans;
long dfs(int u,int p)
{
	long ret=0;
	for(int v:G[u])
	{
		if(v!=p)
		{
			ret+=dfs(v,u);
		}
	}
	ret=(ret*B1+1)%B2;
	ans+=M[ret]++;
	return ret;
}
int main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	cout<<ans<<endl;
}

