Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

map<pair<ll, ll>, int> mm;
ll ans = 0;

ll mod1 = 1000000087;
ll mod2 = 1000000021;
ll mul1 = 999999893;
ll mul2 = 999999929;

vector<int> G[SIZE];

pair<ll, ll> dfs(int now, int back = -1) {
  ll hash1 = 0, hash2 = 0;

  for (int to : G[now]) {
    if (to == back) continue;

    auto p = dfs(to, now);

    hash1 += p.first;
    hash2 += p.second;
  }

  hash1 = ((hash1 % mod1 * mul1) + 1) % mod1;
  hash2 = ((hash2 % mod2 * mul2) + 1) % mod2;

  pair<ll, ll> hash = {hash1, hash2};

  ans += mm[hash];
  mm[hash]++;

  return hash;
}

int main(){
  int N;

  scanf("%d", &N);

  for (int i=0; i+1<N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);

  printf("%lld\n", ans);

  return 0;
}

