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 > 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 dpk(u) as maximum depth of k-ary heap in the subtree of u (including u). Your goal is to compute <image>.

Input

The first line contains an integer n denoting the size of the tree (2 ≤ n ≤ 3·105). 

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.

Output

Output the answer to the task.

Examples

Input

4
1 3
2 3
4 3


Output

21


Input

4
1 2
2 3
3 4


Output

22

Note

Consider sample case one.

For k ≥ 3 all dpk will be equal to 1.

For k = 2 dpk is 2 if <image> and 1 otherwise.

For k = 1 dpk values are (3, 1, 2, 1) respectively.

To sum up, 4·1 + 4·1 + 2·2 + 2·1 + 3 + 1 + 2 + 1 = 21.
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vec[300005];
int niche[300005];
int nije[300005][21], dp[300005][21];
long long ans;
void dfs(int s, int p = 0) {
  niche[s] = 1;
  for (int v : vec[s]) {
    if (v == p) continue;
    dfs(v, s);
    niche[s] = max(niche[s], niche[v] + 1);
  }
  nije[s][1] = dp[s][1] = n;
  for (int i = 2; i < 21; i++) {
    vector<int> tmp;
    for (int v : vec[s]) {
      if (v == p) continue;
      tmp.push_back(nije[v][i - 1]);
    }
    sort(tmp.begin(), tmp.end(), greater<int>());
    for (int j = 0; j < tmp.size(); j++) {
      if (tmp[j] >= j + 1) nije[s][i] = j + 1;
    }
    dp[s][i] = nije[s][i];
    for (int v : vec[s]) {
      if (v == p) continue;
      dp[s][i] = max(dp[s][i], dp[v][i]);
    }
  }
  for (int i = 2; i < 21; i++) ans += (i - 1) * (dp[s][i - 1] - dp[s][i]);
  if (dp[s][21 - 1]) ans += niche[s];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  dfs(1);
  printf("%lld\n", ans);
  return 0;
}
