Example

Input

5
1 2
1 3
1 4
1 5


Output

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

map<LL,LL> mp;
vector<vector<int>> e;

LL dfs(int x, int p){
  LL hs=0;
  for(auto nx:e[x]){
    if(nx==p) continue;
    hs=(hs+dfs(nx, x))%MOD;
  }
  hs=(1007*hs+1)%MOD;
  mp[hs]++;
  return hs;
}

int main(){
  int n;
  cin >> n;
  e=vector<vector<int>>(n);
  int a,b;
  rep(i,n-1){
    cin >> a >> b;
    e[a-1].push_back(b-1);
    e[b-1].push_back(a-1);
  }
  dfs(0, -1);
  LL ans=0;
  for(auto x:mp){
    ans += x.second*(x.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}

