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;
const int mod1 = 1e9 + 7, mod2 = 998244353, maxn = 3e5 + 5, maxlog = 20, K = 26;
const long long infll = 1e18;
const double pi = acos(-1);
int n, h[maxn], f[maxn][20], g[maxn][20];
long long res = 0;
vector<int> gr[maxn];
void dfs(int u, int pa) {
  for (auto v : gr[u]) {
    if (v != pa) {
      dfs(v, u);
      h[u] = max(h[u], h[v] + 1);
    }
  }
  f[u][1] = g[u][1] = n;
  for (long long dep = 2; dep <= 19; ++dep) {
    int lo = 0, hi = n;
    while (lo < hi) {
      int mid = (lo + hi + 1) >> 1;
      int cnt = 0;
      for (auto v : gr[u]) {
        if (v != pa) {
          if (g[v][dep - 1] >= mid) {
            cnt++;
          }
        }
      }
      if (cnt >= mid)
        lo = mid;
      else
        hi = mid - 1;
    }
    g[u][dep] = lo;
    for (auto v : gr[u]) {
      if (v != pa) f[u][dep] = max(f[u][dep], f[v][dep]);
    }
    f[u][dep] = max(f[u][dep], g[u][dep]);
  }
}
void solve() {
  cin >> n;
  for (long long i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs(1, 0);
  for (long long u = 1; u <= n; ++u) {
    res += h[u];
  }
  for (long long u = 1; u <= n; ++u) {
    for (long long dep = 1; dep <= 19; ++dep) {
      int lo = 2;
      if (dep < 19) lo = max(lo, f[u][dep + 1] + 1);
      int hi = f[u][dep];
      if (lo <= hi) {
        res += 1ll * (hi - lo + 1) * (dep - 1);
      }
    }
  }
  res += 1ll * n * n;
  cout << res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
