Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

vector<vector<ll>> g;
map<ll, ll> cnt;
constexpr ll p = 10007, M = 1000000007;
ll hassh(ll pos, ll par) {
	ll ret = 0;
	REP(i, g[pos].size()) {
		ll child = g[pos][i];
		if(child == par) continue;
		ret += hassh(child, pos) * p;
		ret %= M;
	}
	ret++; ret %= M;
	cnt[ret]++;
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	g.resize(n);
	REP(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	hassh(0, -1);
	ll ans = 0;
	for(auto x: cnt) {
		ans += x.second * (x.second - 1) / 2;
	}
	cout << ans << endl;
 	return 0;
}

/* --------------------------------------- */


