Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
typedef unsigned long long ull;
ull B=5575777;
ull ans=0;
int n,a,b;
vector<int> G[MAX_N];
unordered_map<ull,ull> mp;

ull dfs(int pos){
  ull res=0;
  for(int to:G[pos])res+=dfs(to);
  res=res*B+1;
  ans+=mp[res]++;
  return res;
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    G[a].push_back(b);
  }
  dfs(1);
  printf("%lld\n",ans);
  return 0;
}