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;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 300005, S = 550;
int n;
vector<int> g[N];
int p0[N];
int e[N];
vector<int> v0;
void dfs0(int x, int p) {
  e[x] = 1;
  p0[x] = p;
  for (int i = 0; i < g[x].size(); ++i) {
    int h = g[x][i];
    if (h == p) continue;
    dfs0(h, x);
    e[x] += e[h];
  }
  for (int i = 0; i < g[x].size(); ++i) {
    int h = g[x][i];
    if (h == p) {
      swap(g[x][i], g[x].back());
      g[x].pop_back();
      break;
    }
  }
  v0.push_back(x);
}
vector<int> v[N];
int q2;
bool c[N];
int u;
int q[22];
int t[88];
void ubd(int tl, int tr, int x, int y, int pos) {
  while (1) {
    t[pos] += y;
    if (tl == tr) return;
    int m = (tl + tr) / 2;
    if (x <= m) {
      tr = m;
      pos *= 2;
    } else {
      tl = m + 1;
      pos *= 2;
      ++pos;
    }
  }
}
int qry(int tl, int tr, int k, int pos) {
  while (1) {
    if (tl == tr) return tl;
    int m = (tl + tr) / 2;
    if (t[pos * 2 + 1] >= k) {
      tl = m + 1;
      pos *= 2;
      ++pos;
    } else {
      tr = m;
      k -= t[pos * 2 + 1];
      pos *= 2;
    }
  }
}
int dp[N];
int maxu[N];
void dfs(int k) {
  if (k == 1) {
    for (int i = 0; i < n; ++i) {
      int x = v0[i];
      dp[x] = 1;
      for (int i = 0; i < g[x].size(); ++i) {
        int h = g[x][i];
        dp[x] = max(dp[x], dp[h] + 1);
      }
      maxu[x] = dp[x];
    }
    return;
  }
  for (int i = 0; i < n; ++i) {
    int x = v0[i];
    dp[x] = 1;
    maxu[x] = 1;
    if (e[x] <= k) continue;
    for (int i = 0; i < g[x].size(); ++i) {
      int h = g[x][i];
      ++q[dp[h]];
      maxu[x] = max(maxu[x], maxu[h]);
    }
    int s = 0;
    for (int i = u; i >= 1; --i) {
      s += q[i];
      if (s >= k) {
        dp[x] = i + 1;
        break;
      }
    }
    maxu[x] = max(maxu[x], dp[x]);
    for (int i = 0; i < g[x].size(); ++i) {
      int h = g[x][i];
      --q[dp[h]];
    }
  }
}
void solv() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x = i + 1, y = i + 2;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs0(1, 1);
  for (int x = 1; x <= n; ++x) {
    v[((int)(g[x]).size())].push_back(x);
  }
  long long ans = 0;
  for (int i = n; i > S; --i) {
    for (int j = 0; j < v[i].size(); ++j) {
      int x = v[i][j];
      while (!c[x]) {
        c[x] = true;
        ++q2;
        x = p0[x];
      }
    }
    ans += (n + q2);
  }
  for (int i = 1; i <= min(n, S); ++i) {
    u = 1;
    if (i > 1) {
      int t = 1;
      while (t < n) {
        t *= i;
        ++u;
      }
    }
    dfs(i);
    for (int x = 1; x <= n; ++x) ans += maxu[x];
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  solv();
  return 0;
}
