Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<bits/stdc++.h>
using namespace std;

const unsigned long long base = 111111;

unsigned long long rec(int v, const vector< vector<int> > &t,
		       unordered_map<unsigned long long, int> &num){
  unsigned long long res = 1;
  for(int u : t[v]){
    res += rec(u,t,num) * base;
  }
  
  num[res]++;
  return res;
}

int main(){
  int n;
  cin >> n;
  vector< vector<int> > tree(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b; a--; b--;
    tree[a].emplace_back(b);
  }

  unordered_map<unsigned long long, int> num;
  rec(0,tree,num);

  long long ans = 0;
  for(auto x : num){
    ans += (long long)x.second * (x.second-1) / 2;
  }
  cout << ans << endl;
}