Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
vector<ll> paths[100000];
map<l_l, ll> mp;
ll p0 = 1e9 + 7;
ll p1 = 4e9 + 7;
ll b0 = 18254964;
ll b1 = 14852534;
ll ans;


l_l dfs(int now, int from) {
    l_l val = {1, 1};
    for(auto to : paths[now]) {
        if(to == from) continue;
        auto tmp = dfs(to, now);
        tmp.first *= b0;
        tmp.second *= b1;
        val.first += tmp.first;
        val.second += tmp.second;
    }
    val.first %= p0;
    val.second %= p1;
    ans += mp[val];
    mp[val]++;
    return val;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    dfs(0, -1);
    cout << ans << endl;
    return 0;
}
