Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
#define ull unsigned long long
#define pb push_back

map<ull, ull>ans;
vector<int>ma[100005];

ull dfs(int pos, int fa) {
    ull x = 1ull;
    int sz = ma[pos].size();
    for(int i = 0; i < sz; i ++){
        int to = ma[pos][i];
        if(to == fa) continue;
        x += (19 * dfs(to, pos));
    }
    ans[x] ++;
    return x;
}

int main () {
    int n, a, b;
    scanf("%d", &n);
    for(int i = 0; i < n - 1; i ++) {
        scanf("%d%d", &a, &b);
        ma[a].pb(b);
        ma[b].pb(a);
    }
    ans.clear();
    map<ull, ull> :: iterator it;
    dfs(1, -1);
    ull res = 0ull;
    for(it = ans.begin(); it != ans.end(); it ++) {
        ull tm = it -> second;
        res += tm * (tm - 1) / 2;
    }
    printf("%llu\n", res);
}