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 maxn = 3E5 + 77;
const int log2maxn = 23;
struct EDGE {
  int to, next;
} edges[maxn * 2];
int cEdge = 1, head[maxn];
void addEdge(int from, int to) {
  edges[cEdge] = (EDGE){to, head[from]};
  head[from] = cEdge++;
}
int N, V[maxn][log2maxn];
int X[maxn], Y[maxn], ce = 0, C[maxn], K[maxn];
void dfs1(int u, int f) {
  for (int k = head[u]; k; k = edges[k].next) {
    int v = edges[k].to;
    if (v == f) continue;
    X[ce] = u;
    Y[ce] = v;
    ++ce;
    ++C[u];
    dfs1(v, u);
  }
}
void dfs2(int u) {
  for (int d = 1; d < log2maxn; ++d) V[u][d] = max(V[u][d], 1);
  for (int k = head[u]; k; k = edges[k].next) {
    int v = edges[k].to;
    dfs2(v);
    for (int d = 1; d < log2maxn; ++d) V[u][d] = max(V[u][d], V[v][d]);
  }
}
int dfs3(int u, long long &ans) {
  int d = 1;
  for (int k = head[u]; k; k = edges[k].next) {
    int v = edges[k].to;
    d = max(d, dfs3(v, ans) + 1);
  }
  ans += d;
  return d;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) V[i][1] = N;
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    addEdge(u, v);
    addEdge(v, u);
  }
  dfs1(1, 0);
  cEdge = 1;
  memset(head, 0, sizeof(head));
  for (int i = 0; i < ce; ++i) addEdge(X[i], Y[i]);
  for (int d = 2; d < log2maxn; ++d)
    for (int u = 1; u <= N; ++u) {
      for (int k = head[u]; k; k = edges[k].next) {
        int v = edges[k].to, w = V[v][d - 1];
        if (w >= C[u]) w = C[u];
        K[w]++;
      }
      for (int i = C[u] - 1; i >= 0; --i) K[i] += K[i + 1];
      for (int i = C[u]; i; --i)
        if (K[i] >= i) {
          V[u][d] = i;
          break;
        }
      for (int i = 0; i <= C[u]; ++i) K[i] = 0;
    }
  dfs2(1);
  long long ans = 0;
  for (int u = 1; u <= N; ++u) {
    for (int d = 1; d < log2maxn - 1; ++d) {
      if (V[d][d] < V[d][d + 1]) cerr << "??" << endl;
      ans += d * (V[u][d] - V[u][d + 1]);
    }
  }
  dfs3(1, ans);
  cout << ans << endl;
}
