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>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 300000 + 10, M = 20 + 2;
int n;
vector<int> V[N];
int depth[N];
int d[M][N], d_max[M][N];
void dfs(int v, int parent) {
  depth[v] = 1;
  for (int i = 0; i < (((int)((V[v]).size()))); ++i) {
    int to = V[v][i];
    if (to == parent) continue;
    dfs(to, v);
    depth[v] = max(depth[v], depth[to] + 1);
  }
  for (int i = (int)(2); i <= (int)(M - 1); ++i) {
    d[i][v] = 1;
    int b = 1, e = n;
    while (b < e) {
      int m = (b + e + 1) / 2;
      int cnt = 0;
      for (int j = 0; j < (((int)((V[v]).size()))); ++j) {
        int to = V[v][j];
        if (to == parent) continue;
        if (d[i - 1][to] >= m) cnt++;
      }
      if (cnt >= m)
        b = m;
      else
        e = m - 1;
    }
    d[i][v] = max(d[i][v], b);
  }
}
void dfs2(int v, int parent) {
  for (int j = 0; j < (M); ++j) d_max[j][v] = d[j][v];
  for (int i = 0; i < (((int)((V[v]).size()))); ++i) {
    int to = V[v][i];
    if (to == parent) continue;
    dfs2(to, v);
    for (int j = 0; j < (M); ++j) d_max[j][v] = max(d_max[j][v], d_max[j][to]);
  }
}
void sol() {
  scanf("%d", &n);
  for (int i = 0; i < (n - 1); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    V[x].push_back(y);
    V[y].push_back(x);
  }
  for (int i = 1; i <= (int)(n); ++i) d[1][i] = n;
  dfs(1, -1);
  dfs2(1, -1);
  long long ans = 0;
  for (int i = 1; i <= (int)(n); ++i) {
    ans += depth[i];
    for (int m = 1; m <= (int)(M - 1); ++m) ans += max(0, d_max[m][i] - 1);
  }
  cout << ans << endl;
}
void clear() {}
void once() {}
void solve() {
  int T;
  T = 1;
  once();
  for (int i = 1; i <= (int)(T); ++i) {
    clear();
    sol();
  }
}
void testgen() {
  FILE* f = fopen("input.txt", "w");
  int n = 2000, m = 1000000000;
  fprintf(f, "1\n", n);
  fprintf(f, "%d %d\n", n, m);
  srand(time(NULL));
  for (int i = 0; i < (n); ++i) fprintf(f, "%d\n", rand() % 2000);
  fclose(f);
}
int main() {
  cout << fixed;
  cout.precision(10);
  cerr << fixed;
  cerr.precision(3);
  solve();
  return 0;
}
