Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) FOR(i, 0, (n))
#define ALL(a) (a.begin(), a.end())
typedef vector<int> vi;

int64_t h(const vector<vi> &t, int i, int p, vi &v) {
    int64_t res = 1;
    for (int c : t[i]) {
        if (c == p) continue;
        res += 1000000009 * h(t, c, i, v);
    }
    v[i] = res;
    return res;
}

int main() {
    int n;
    cin>>n;
    vector<vi> t(n);
    REP(i,n-1) {
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    vi v(n);
    h(t, 0, -1, v);
    map<int64_t, int> m;
    int64_t cnt = 0;
    REP(i,n) {
        cnt += m[v[i]];
        ++m[v[i]];
    }
    cout << cnt << endl;
    return 0;
}