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> P;

#define EACH(i, a) for(auto&& i:a)
#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for(ll i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define ALL(v) (v).begin(),(v).end()

const ll linf = 1e18;
const ll inf = 1e9;

template<class T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}

ll A = 1007, modA = 1e9+7;

vector< vector<ll> > G;
vector<ll> h;

ll add(ll a, ll b) {
    return (a + b) % modA;
}
ll mul(ll a, ll b) {
    return a * b % modA;
}
ll dfs(ll v, ll prev) {
    ll res = 1;
    EACH(to, G[v]) {
        if (to == prev) continue;
        res = add(res, mul(A, dfs(to, v)));
    }
    return h[v] = res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    G.clear(); G.resize(n);
    ll root = 0;
    REP(i, n-1) {
        ll a, b; cin >> a >> b; --a, --b;
        G[a].pb(b);
        G[b].pb(a);
    }
    h.assign(n, -1);
    dfs(0, -1);
    map<ll, ll> cnt;
    ll ans = 0;
    REP(i, n) {
        ans += cnt[h[i]];
        cnt[h[i]]++;
    }
    cout << ans << endl;
}