Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;
const ll m1 = 10007;
const ll m2 = 10009;
const ll mod1 = 100000007;
const ll mod2 = 100000009;

vi G[MAX_N];
bool flag[MAX_N];
pll sz[MAX_N];
map<pll,ll> mp;

void dfs(int u)
{
    flag[u] = true;
    rep(i,len(G[u])){
        if(!flag[G[u][i]]){
            dfs(G[u][i]);
            sz[u].fi += sz[G[u][i]].fi;
            sz[u].se += sz[G[u][i]].se;
        }
    }
    sz[u].fi = sz[u].fi*m1%mod1;
    sz[u].se = sz[u].se*m2%mod2;
    sz[u].fi++,sz[u].se++;
    mp[sz[u]]++;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1),G[b-1].pb(a-1);
    }
    dfs(0);
    ll res = 0;
    each(it,mp){
        res += it.se*(it.se-1)/2;
    }
    cout << res << "\n";
    return 0;
}