Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

using ull = unsigned long long;

#define MAX_N 100000

int N;
vector<int> graph[MAX_N];

ull base = 100000007; //base for rolling hash
map<ull, int> mp;

ull dfs(int v, int p) {
  ull res = 1;
  for(int u : graph[v]) {
    if(u == p) continue;
    res += dfs(u, v)*base;
  }
  mp[res]++;
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(0, -1);
  int ans = 0;
  for(auto p : mp) {
    ans += p.second*(p.second-1) / 2;
  }
  cout << ans << endl;

  return 0;
}