Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int V;
	vvi g;
	map<ull,ll> m;
	vi used;
	ull dfs(int v){
		used[v]=1;
		ull H=1;
		for(int i=0;i<g[v].size();i++){
			int u=g[v][i];
			if(!used[u]) H+=dfs(u)*mod;
		}
		m[H]++;
		return H;
	}
	public:
	Graph(int v){
		V=v;
		g=vvi(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(t);
		g[t].push_back(s);
	}
	ll solve(){
		ll res=0;
		used=vi(V);
		dfs(0);
		for(auto i=m.begin();i!=m.end();i++){
			ll v=i->second;
			res+=v*(v-1)/2;
		}
		return res;
	}
};

int n;

int main(){
	cin>>n;
	Graph g(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		g.add_edge(u-1,v-1);
	}
	cout<<g.solve()<<endl;
}