Example

Input

5
1 2
1 3
1 4
1 5


Output

6
/*  -*- coding: utf-8 -*-
 *
 * 2784.cc: Similarity of Subtrees
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int P = 4073;
const int MOD = 1000000009;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;

struct Trp {
  int n, d, h;
  Trp() {}
  Trp(int _n, int _d, int _h): n(_n), d(_d), h(_h) {}

  bool operator==(const Trp &t) const {
    return n == t.n && d == t.d && h == t.h;
  }

  bool operator<(const Trp &t) const {
    return n < t.n || (n == t.n && (d < t.d || (d == t.d && h < t.h)));
  }

  void print() { printf("(%d,%d,%d)\n", n, d, h); }
};

/* global variables */

vi nbrs[MAX_N];
int prts[MAX_N], cns[MAX_N];
Trp ts[MAX_N];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);

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

  fill(ts, ts + n, Trp(1, 0, 1));
  
  prts[0] = -1;
  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = prts[u];
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (v != up) {
	prts[v] = u;
	cns[u]++;
	q.push(v);
      }
    }
  }

  for (int i = 0; i < n; i++)
    if (! cns[i]) q.push(i);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int &up = prts[u];

    if (up >= 0) {
      ts[up].n += ts[u].n;
      setmax(ts[up].d, ts[u].d + 1);
      ts[up].h = (ts[up].h + (ll)ts[u].h * P) % MOD;
      if (--cns[up] == 0) q.push(up);
    }
  }
  sort(ts, ts + n);
  //for (int i = 0; i < n; i++) ts[i].print();

  ll c = 0;
  for (int i = 0, j = 0; i < n;) {
    while (j < n && ts[i] == ts[j]) j++;
    int d = j - i;
    c += (ll)d * (d - 1) / 2;
    i = j;
  }

  printf("%lld\n", c);
  return 0;
}

