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 m, k;
long long ans;
const int N = 330000;
int h[N], dp[N], mdp[N], cnt[N], par[N], chd[N];
vector<int> adj[N];
vector<int> V;
void dfs(int u, int p) {
  V.push_back(u);
  par[u] = p;
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
  chd[u] = adj[u].size() - (u != 1);
  for (int v : adj[u]) {
    if (v == p) continue;
    h[u] = max(h[u], h[v] + 1);
    chd[u] = max(chd[u], chd[v]);
  }
  ans += h[u];
}
int from[N], cc[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  m = 0;
  ans = 1LL * n * n;
  m = 1;
  dfs(1, 0);
  reverse(V.begin(), V.end());
  int sum = 0;
  int _m = 1;
  for (m = 2; 1LL * m * (m + 1) + 1 <= n; m++) {
    long long s = 1, t = 1;
    k = 0;
    while (s <= n) t *= m, s += t, k++;
    for (int i = 1; i <= n; i++) mdp[i] = 0;
    sum += k;
    if (k >= 4) {
      for (int u : V) {
        for (int v : adj[u]) {
          if (v == par[u]) continue;
          mdp[u] = max(mdp[u], mdp[v]);
        }
        int c = adj[u].size() - (u != 1);
        dp[u] = 0;
        if (mdp[u] < k - 1) {
          if (c >= m) {
            for (int j = 0; j < k; j++) cnt[j] = 0;
            for (int v : adj[u]) {
              if (v == par[u]) continue;
              cnt[dp[v]]++;
            }
            for (int j = k - 2; j >= 0; j--) {
              cnt[j] += cnt[j + 1];
              if (cnt[j] >= m) {
                dp[u] = j + 1;
                break;
              }
            }
            mdp[u] = max(mdp[u], dp[u]);
          }
        }
        ans += mdp[u];
      }
      _m = m;
    } else {
      for (int u : V) {
        cc[u] = adj[u].size() - (u != 1);
        from[u] = 0;
        int cn = 0;
        for (int v : adj[u]) {
          if (v == par[u]) continue;
          cnt[cn++] = cc[v];
          from[u] = max(from[u], from[v]);
        }
        sort(cnt, cnt + cn);
        int t = 0;
        for (int j = cn - 1; j >= 0; j--) {
          if (cnt[j] < cn - j) break;
          t = max(t, cn - j);
        }
        from[u] = max(from[u], t);
        if (from[u] >= m) ans += from[u] - m + 1;
      }
      break;
    }
  }
  for (int i = 0; i <= n; i++) cnt[i] = 0;
  for (int i = 1; i <= n; i++) cnt[chd[i]]++;
  for (int i = n - 1; i >= 0; i--) cnt[i] += cnt[i + 1];
  for (m = _m + 1; m <= n; m++) ans += cnt[m];
  cout << ans << endl;
  return 0;
}
