Example

Input

5
1 2
1 3
1 4
1 5


Output

6
#include<bits/stdc++.h>

using namespace std;

#define rep(i,n) for(i = 0; i<n; i++)
#define repl(i,n) for(i = 1; i<=n; i++)

#define sz(x)   (int)x.size()
#define pb      push_back
#define all(x)  x.begin(), x.end()
#define uu      first
#define vv  second
#define mem(x,y) memset(x,y,sizeof(x))
#define sdi(x) scanf("%d",&x)
#define sdii(x,y) scanf("%d %d",&x,&y)
#define sdiii(x,y,z)  scanf("%d %d %d",&x,&y,&z)
#define sdl(x) scanf("%lld",&x)
#define sdll(x,y) scanf("%lld %lld",&x,&y)
#define sdlll(x,y,z)  scanf("%lld %lld %lld",&x,&y,&z)
#define sds(x) scanf("%s",s);
#define pfi(x) printf("%d\n",x)
#define pfii(x,y) printf("%d %d\n",x,y)
#define pfiii(x,y,z) printf("%d %d %d\n",x,y,z)
#define pfl(x) printf("%lld\n",x)
#define pfll(x,y) printf("%lld %lld\n",x,y)
#define pflll(x,y,z) printf("%lld %lld %lld\n",x,y,z)

#define eps 1e-9
#define OK  cerr<< "OK" << '\n'
#define DB(x) cerr << #x " = " << x << '\n'

#define FRE(i,a,b) for(i = a; i<=b; i++)
#define FRL(i,a,b) for(i = a; i<b; i++)
#define un(x) x.erase(unique(all(x)),x.end())
#define sf(x) scanf("%d",&x)
#define sff(x,y) scanf("%d %d",&x,&y)
#define sfff(x,y,z)  scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z)  scanf("%lld %lld %lld",&x,&y,&z)
#define D(x)        cerr << #x " = " << x << '\n'
#define DBG         cerr << "Hi" << '\n'
#define PI          acose(-1.00)
#define xx          first
#define yy          second

typedef double db;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

inline int setBit(int N, int pos) { return N=N|(1<<pos);}
inline int resetBit(int N, int pos) {return N=N &~(1<<pos);}
inline bool checkBit(int N, int pos) {return (bool) (N & (1<<pos));}


//int fx[] = {+0, +0, +1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, -1, -1};


const LL  mod[] = { 2078526727, 2117566807 };
const LL base[] = { 1572872831, 1971536491 };

const int MAX = 100005;
int n;
vector <int> graph[MAX];
unordered_map <LL, LL> mapp;

pair <LL, LL> dfs(int u, int par=-1) {
    pair <LL, LL> ret = { 0ll, 0ll };
    for(auto v:graph[u]) {
        if(v == par) continue;
        auto now = dfs(v, u);
        ret.uu += now.uu;
        if(ret.uu >= mod[0]) ret.uu -= mod[0];
        ret.vv += now.vv;
        if(ret.vv >= mod[1]) ret.vv -= mod[1];
    }
    LL here = (ret.uu << 32) ^ ret.vv;
    if(mapp[here] == 0) mapp[here] = 1;
    else mapp[here]++;

    ret.uu *= base[0];
    ret.uu %=  mod[0];
    ret.vv *= base[1];
    ret.vv %=  mod[1];
    ret.uu++;
    if(ret.uu >= mod[0]) ret.uu -= mod[0];
    ret.vv++;
    if(ret.vv >= mod[1]) ret.vv -= mod[1];
    return ret;
}

int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    int i, u, v;
    LL ans = 0;

    sdi(n);
    rep(i, n-1) {
        sdii(u, v);
        u--, v--;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    dfs(0);
    for(auto x:mapp) {
        LL now = x.vv;
        ans += ((now)*(now-1)) / 2;
    }
    pfl(ans);

    return 0;
}