You're given a tree with *n* vertices rooted at 1.

We say that there's a *k*-ary heap of depth *m* located at *u* if the following holds:
 -  For *m* = 1 *u* itself is a *k*-ary heap of depth 1. -  For *m* &gt; 1 vertex *u* is a *k*-ary heap of depth *m* if at least *k* of its children are *k*-ary heaps of depth at least *m* - 1. 
Denote *dp*<sub class="lower-index">*k*</sub>(*u*) as maximum depth of *k*-ary heap in the subtree of *u* (including *u*). Your goal is to compute <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/021432cac1fbfdf91e34779ff99d535e19729d02.png" style="max-width: 100.0%;max-height: 100.0%;"/>.
The first line contains an integer *n* denoting the size of the tree (2 ≤ *n* ≤ 3·10<sup class="upper-index">5</sup>). 

The next *n* - 1 lines contain two integers *u*, *v* each, describing vertices connected by *i*-th edge.

It's guaranteed that the given configuration forms a tree.
Consider sample case one.

For *k* ≥ 3 all *dp*<sub class="lower-index">*k*</sub> will be equal to 1.

For *k* = 2 *dp*<sub class="lower-index">*k*</sub> is 2 if <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/0a527e618740bc1e83327ce591b684aa4351c914.png" style="max-width: 100.0%;max-height: 100.0%;"/> and 1 otherwise.

For *k* = 1 *dp*<sub class="lower-index">*k*</sub> values are (3, 1, 2, 1) respectively.

To sum up, 4·1 + 4·1 + 2·2 + 2·1 + 3 + 1 + 2 + 1 = 21.



def BFS(n, Adj):
	L = [(0, 0, -1)]
	Levels = [[] for l in range(n)]
	Parents = [-1 for v in range(n)]

	while L:
		u, l, p = L.pop()
		#print('{} at level {}'.format(u, l), end = ' ')
		Levels[l].append(u)
	
		for v in  Adj[u]:
			if v != p:
				L.append( (v, l+1, u) )
				Parents[v] = u
				#print(v, end = ' ')

		#print()

	return [level for level in Levels if level], Parents



if __name__ == '__main__':
	n = int(input())
	Adj = [ [] for v in range(n) ]

	for e in range(n-1):
		u, v = map( lambda x: int(x)-1, input().split() )
		Adj[u].append(v)
		Adj[v].append(u)

	# DP[k][u] maximum depth of a k-ary heap rooted at u
	DP = [ [1 for u in range(n)] for k in range(n) ]

	Levels, Parents = BFS(n, Adj)

	for l in Levels[len(Levels)-2::-1]:
		for u in l:
			# T[k][d] number of k-ary children with depth k
			T = [ [0 for d in range(n)] for k in range(n)]
			for v in Adj[u]:
				if v != Parents[u]:
					for k in range(n):
						DP[k][u] = max(DP[k][u], DP[k][v])
						T[k][ DP[k][v]-1 ] += 1

			#for k in range(n):
			#	print(k,  end=': ')
			#	for d in range(n):
			#		print((d, T[k][d]), end= ' ')

			#	print()

			for k in range(n-1, -1, -1):
				numchildren = 0
				for d in range(n-1, -1, -1):
					numchildren += T[k][d]	
					if numchildren > k:
						for k2 in range(k+1):
							DP[k2][u] = max(DP[k2][u], d+2)
						break

			#print(u, ':', [ DP[k][u] for k in range(n)])

	print( sum( [ sum(DP[k])  for k in range(n)] ) )
