Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 111111
typedef unsigned long long ull;
ull MOD=1000000007LL;
vector<int> G[MAX_N];
int n;
map<ull,ull> m;
ull dfs(int p){
  ull res=1LL;
  for(int i=0;i<(int)G[p].size();i++)
    res+=dfs(G[p][i])*MOD;
  m[res]++;
  return res;
}
int main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    G[a].push_back(b);
  }
  dfs(1);
  ull ans=0;
  for(auto i:m) ans+=i.second*(i.second-1)/2;
  cout<<ans<<endl;
  return 0;
}