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;
long long ans;
int dp[300000 + 5][20], n;
vector<int> e[300000 + 5];
inline void upd(int &x, int y) {
  if (x < y) x = y;
}
int dfs(int now, int fa) {
  int mxdep = 0;
  for (auto v : e[now])
    if (v != fa) upd(mxdep, dfs(v, now));
  mxdep++;
  ans += mxdep;
  dp[now][1] = n;
  for (int m = 2; m <= 19; m++) {
    vector<int> tmp;
    for (auto v : e[now])
      if (v != fa) tmp.push_back(dp[v][m - 1]);
    sort(tmp.begin(), tmp.end(), greater<int>());
    int t = 1;
    while (t <= (int)tmp.size() && tmp[t - 1] >= t) t++;
    dp[now][m] = t - 1;
    upd(dp[now][m], 1);
  }
  return mxdep;
}
void dfs2(int now, int fa) {
  for (auto v : e[now])
    if (v != fa) {
      dfs2(v, now);
      for (int m = 1; m <= 19; m++) upd(dp[now][m], dp[v][m]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 0);
  dfs2(1, 0);
  for (int now = 1; now <= n; now++)
    for (int m = 1; m <= 18; m++)
      ans += 1ll * m * (dp[now][m] - dp[now][m + 1]);
  printf("%lld\n", ans);
  return 0;
}
