Example

Input

5
1 2
1 3
1 4
1 5


Output

6
import sys
sys.setrecursionlimit(10000000)

MOD = 10 ** 30 + 7

N = input()
E = [[] for i in range(N)]

for i in range(N - 1):
    a, b = map(int, raw_input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)

m = {}

def func(num, pre):
    S = 0
    for to in E[num]:
        if to != pre:
            S += func(to, num)
    S *= 1000000007
    S += 1
    S %= MOD
    if not S in m:
        m[S] = 1
    else:
        m[S] += 1
    return S

func(0, -1)

ans = 0
for key in m:
    ans += m[key] * (m[key] - 1) / 2
print ans
