Example

Input

5
1 2
1 3
1 4
1 5


Output

6
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
const ll base = 1013;

int N, hashes[100010];
vector<int> G[100010];

void dfs(int cur, int par=-1) {
    for(auto to : G[cur]) {
        if(to == par) continue;
        dfs(to, cur);
        (hashes[cur] += hashes[to]) %= MOD;
    }
    (hashes[cur] *= base) %= MOD;
    (hashes[cur] += 1) %= MOD;
}

map<int, int> memo;
signed main() {
    cin >> N;
    for(int i=0; i<N-1; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dfs(0);
    for(int i=0; i<N; i++) memo[hashes[i]]++;

    int ans = 0;
    for(auto e : memo) ans += e.second * (e.second - 1) / 2;
    cout << ans << endl;
    return 0;
}

