Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define DOM 1000000009
#define BASE 1000000021

using P = pair<int,pair<long,long>>;
// depth, hash1, hash2

vector<int> tree[100005];
map<pair<int,pair<long,long>>,int> memo;

P dfs(int v, int from){
  long h1 = 1, h2=1;
  int d = 1;
  for(auto to : tree[v]) if(to!=from){
    P p = dfs(to,v);
    d = max(d, p.fi+1);
    h1 += p.se.fi*MOD;
    h1 %= BASE;
    h2 += p.se.se*DOM;
    h2 %= BASE;
  }
  P p = mp(d,mp(h1,h2));
  memo[p]++;
  return p;
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    tree[a].pb(b);
    tree[b].pb(a);
  }

  dfs(0,-1);

  long ans = 0;
  for(auto &p : memo){
    ans += (long)p.se * (p.se-1) / 2;
  }

  cout << ans << endl;

  return 0;
}