Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define dbg(...) cerr<<"["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"<<endl;
typedef vector<int> VI;
typedef long long ll;
typedef pair<double,int> PII;
const ll p=998244353;
const ll mod=1e9+7;
const int maxn=1e5+100;
map<ll,int> mp;

struct node
{
    int to,next;
}e[maxn*2];

int tol=0;
int head[maxn];
void add(int u,int v)
{
    e[++tol].to=v,e[tol].next=head[u],head[u]=tol;
}
ll dfs(int u,int f)
{
    ll ans=1;
    for(int i=head[u];i;i=e[i].next)
    {
        int v=e[i].to;
        if(v==f) continue;
        ans=(ans+dfs(v,u)*mod%p)%p;
    }
    mp[ans]++;
    return ans;
}


int main()
{
    int n;
    scanf("%d",&n);
    rep(i,1,n)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        add(u,v),add(v,u);
    }
    mp.clear();
    dfs(1,0);
    ll ans=0;
    map<ll,int>::iterator it;
    for(it=mp.begin();it!=mp.end();it++) ans+=1ll*(it->se)*(it->se-1)/2;
    printf("%lld\n",ans);
    return 0;
}