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>
std::vector<int> node[524288];
int mk[524288][32], km[524288][32];
int dpmk[524288][32], dpkm[524288][32];
long long int ans;
int a[524288];
int na;
int n, k, m;
void dfs(int p, int u) {
  0;
  for (auto v : node[u])
    if (v != p) dfs(u, v);
  for (int i = 1; i < k; ++i) {
    na = 0;
    for (auto v : node[u])
      if (v != p) a[na++] = mk[v][i];
    if (na >= i) {
      std::nth_element(a, a + na - i, a + na);
      dpmk[u][i] = mk[u][i] = a[na - i] + 1;
    } else
      dpmk[u][i] = mk[u][i] = 1;
    for (auto v : node[u])
      if (v != p) dpmk[u][i] = std::max(dpmk[u][i], dpmk[v][i]);
    ans += dpmk[u][i];
    0;
  }
  dpkm[u][1] = km[u][1] = n;
  ans += n - (k - 1);
  for (int i = 2; i < m; ++i) {
    na = 0;
    for (auto v : node[u])
      if (v != p) a[na++] = km[v][i - 1];
    std::sort(a, a + na);
    km[u][i] = 0;
    for (int j = 1; j <= na; ++j)
      if (a[na - j] >= j) km[u][i] = j;
    dpkm[u][i] = km[u][i];
    for (auto v : node[u])
      if (v != p) dpkm[u][i] = std::max(dpkm[u][i], dpkm[v][i]);
    ans += std::max(0, dpkm[u][i] - (k - 1));
    0;
  }
}
int main() {
  scanf("%d", &n), k = std::min(n + 1, 32), m = std::min(n + 1, 32);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
    node[v].push_back(u);
  }
  dfs(1, 1);
  printf("%lld\n", ans);
  return 0;
}
