from collections import defaultdict, deque import sys sys.setrecursionlimit(10**6) N = int(input()) degs = [0] * N adj = defaultdict(list) for _ in range(N-1): U, V = map(lambda x: int(x)-1, input().split()) adj[U].append(V) adj[V].append(U) degs[U] += 1 degs[V] += 1 leaves = [] for i in range(N): if degs[i] == 1: leaves.append(i) def f(w): used = set() def dfs(vs): hd = vs[0] tl = vs[-1] mi = min(hd, tl) ma = max(hd, tl) if mi != -1: used.add((mi, ma)) for to in adj[tl]: if to == vs[-2]: continue xs = vs[1:] + [to] dfs(xs) for v in leaves: vs = [-1] * w vs[-1] = v dfs(vs) return len(used) ans = f(2) + f(3) + f(4) print(ans)