Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<set>
#include<bitset>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#define INF 0x3f3f3f3f
#define inf 2*0x3f3f3f3f
#define llinf 1000000000000000000
#define pi acos(-1.0)
#define mod 1000000007
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt rt<<1
#define rrt rt<<1|1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define lb(x) (x&-x)
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gc(x) scanf("%c",&x)
#define gc2(x,y) scanf("%c%c",&x,&y)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
/***********************************************/
int n,x,y;
vector<int>v[100005];
ll f[100005],num;
void dfs(int x,int pr)
{
    f[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        if(v[x][i]==pr)continue;
        dfs(v[x][i],x);
        f[x]+=f[v[x][i]]*num;
    }
}
ll cal()
{
    map<ll,int>mm;
    ll sum=0;
    rep(i,1,n+1)
    {
        sum+=mm[f[i]];
        mm[f[i]]++;
    }
    return sum;
}
int main()
{
    gi(n);
    srand((ull)time(0));
    rep(i,0,n-1)
    {
        gi2(x,y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll ans=1e16;
    rep(i,0,10)
    {
        num=rand();
        dfs(1,1);
        ans=min(ans,cal());
    }
    printf("%lld\n",ans);
    return 0;
}