Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long int;

const ll P = 1013;
const ll MOD = 1000000007;

int N;
ll hash_tab[100010];
map<ll, int> cnt;
vector<int> G[100010];

void dfs(int cur, int par=-1) {
  for(auto to : G[cur]) {
    if(to == par) continue;
    dfs(to, cur);
    (hash_tab[cur] += hash_tab[to]) %= MOD;
  }
  (hash_tab[cur] *= P) %= MOD;
  (hash_tab[cur] += 1) %= MOD;
  cnt[ hash_tab[cur] ]++;
}

int main() {
  cin >> N;
  for(int i=0; i<N-1; i++) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  dfs(0);
  ll ans = 0;
  for(auto x : cnt) {
    ll tmp = x.second;
    ans += tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

