Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N;
vector<ll> E[100000];
map<pll, ll> cnt;

pll dfs(ll v, ll p) {
  const ll mod1 = 1000000007;
  const ll mod2 = 1000000009;

  pll ret = pll(1, 1);
  for(ll u : E[v]) if(u != p) {
    pll x = dfs(u, v);
    (ret.fi += x.fi * 12345 % mod1) %= mod1;
    (ret.se += x.se * 12345 % mod2) %= mod2;
  }
  cnt[ret]++;

  return ret;
}

int main(void) {
  cin >> N;
  REP(i, 0, N - 1) {
    ll A, B; cin >> A >> B; A--; B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }

  dfs(0, -1);

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