Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>

#define MAXN 100005

using namespace std;

struct edge
{
	int y,next;
};

edge v[2*MAXN];
int head[MAXN];
int tot = 0;
long long ans = 0;
map<unsigned long long,int> S;

void add(int x,int y)
{
	tot++;
	v[tot].y = y;
	v[tot].next = head[x];
	head[x] = tot;
}

unsigned long long dfs(int x,int fa)
{
	unsigned long long temp = 1;
	for (int i=head[x];i;i=v[i].next)
	{
		if (v[i].y == fa) continue;
		temp += 131*dfs(v[i].y,x);
	}
	ans += S[temp];
	S[temp]++;
	return temp;
}

int main()
{
	int x,y,n;
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}

	S.clear();
	ans = 0;
	dfs(1,0);

	cout << ans << endl;
	return 0;
}