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<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

vector<int> G[100000];

const ll H = (1LL<<30);
const ll B = 100003;

ll ans=0;
map<ll,int> hs;

ll dfs(int cur,int bef,int depth){
    ll ret = 0;
    bool isLeaf=true;
    for(auto &e:G[cur]){
        if(e==bef)continue;
        isLeaf = false;
        ret += dfs(e,cur,depth+1);
    }
    
    if(isLeaf){
        if(hs.count(1)){
            ans+=hs[1];
        }
        hs[1]++;
        return 1;
    }
    
    if(hs.count((ret*B + 1)%H)){
        ans+=hs[(ret*B + 1)%H];
    }
    hs[(ret*B + 1)%H]++;
    return (ret*B + 1)%H;
}


int main(){
    int v;
    cin>>v;
    rep(i,v-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    ll res = dfs(0,-1,0);
    
    cout<<ans<<endl;
}