Example

Input

5
1 2
1 3
1 4
1 5


Output

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

using namespace std;

#define read() freopen("input.txt", "r", stdin)

#define ll64 long long
#define BASE 100000007
#define MOD 100000077

ll64 BP[300010];
bool visited[100010];
vector<int> graph[100010];
map<ll64, ll64> C_M;

ll64 dfs(int u)
{
    //printf("=>%d\n", u);
    visited[u] = true;
    ll64 hsh = 1;
    for(auto v: graph[u]){
        if(!visited[v]){
            hsh += (dfs(v) * BASE) % MOD;
            hsh %= MOD;
        }
    }
    C_M[hsh] += 1;
    return hsh;
}

int main()
{
    //read();
    ll64 temp = 1;
    for(int i = 0; i < 200000; i++){
        BP[i] = temp;
        temp = (temp * BASE) % MOD;
    }
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N - 1; i++){
        int u, v;
        scanf("%d%d", &u, &v);
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    dfs(1);
    ll64 ans = 0;
    for(auto &it: C_M){
        ll64 x = it.second;
        ans += (x * (x - 1)) / 2;
    }
    printf("%lld\n", ans);
}