Example

Input

5
1 2
1 3
1 4
1 5


Output

6

#include<algorithm>
#include<vector>
 #include<cstring>
#include<string>
#include<iomanip>
#include<cstdio>
#include<stack>
#include<iostream>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
#define sf scanf
#define pf printf
#define mem(a,b) memset(a,b,sizeof(a));
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define mod 998244353
#define N 100020
#define M 400020
#define ULL unsigned long long
#define LL long long
#define inf 0x3f3f3f3f
map<ULL,LL>mp;
vector<int>g[N];
ULL dp[N];
LL ans;int n;
const ULL b=1000000007;
void dfs(int u,int fa){
    dp[u]=1;
    for(int i=0;i<g[u].size();++i){
        int v=g[u][i];
        if(v==fa)continue;
        dfs(v,u);
        dp[u]+=dp[v]*b;
    }
    ans+=mp[dp[u]];
    mp[dp[u]]++;
}
int main(){
    sf("%d",&n);
        ans=0;
        rep(i,1,n-1){
            int u,v;sf("%d%d",&u,&v);
            g[u].push_back(v);g[v].push_back(u);
        }
        dfs(1,1);
        cout<<ans<<'\n';
}