Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
typedef unsigned long long ull;
const ull a=8931919,p=1000000007,q=1000000009;
 
int N;
vint G[100000];
 
int sz[100000];
map<pint,int>cnt[111111];
pint dfs(int v,int par){
    ull hp=1,hq=1;
    sz[v]=1;
    for(auto u:G[v]){
        if(u==par)continue;
        ull gp,gq;
        tie(gp,gq)=dfs(u,v);
        sz[v]+=sz[u];
        hp=(hp+gp*a)%p;
        hq=(hq+gq*a)%q;
    }
    cnt[sz[v]][pint(hp,hq)]++;
    return pint(hp,hq);
}
signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }
    dfs(0,-1);
 
    int ans=0;
    reps(i,1,N+1){
        each(it,cnt[i]){
            ans+=it->se*(it->se-1)/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}