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;
template <typename T>
void maxify(T& x, const T& y) {
  y > x && (x = y);
}
typedef const int& ci;
struct node {
  int v, nxt;
  __inline__ __attribute__((always_inline)) node() {}
  __inline__ __attribute__((always_inline)) node(ci _v, ci _nxt)
      : v(_v), nxt(_nxt) {}
};
struct graph {
  int head[300000 + 1], cnt;
  node edge[300000 << 1];
  __inline__ __attribute__((always_inline)) void build() {
    memset(head, 0, sizeof(head)), cnt = 0;
  }
  __inline__ __attribute__((always_inline)) void insert(ci u, ci v) {
    push(u, v);
    push(v, u);
  }
  __inline__ __attribute__((always_inline)) void push(ci u, ci v) {
    edge[++cnt] = node(v, head[u]);
    head[u] = cnt;
  }
};
graph g;
int dp1[300000 + 1][20 + 1], dp2[300000 + 1][20 + 1], dp3[300000 + 1];
int son[300000 + 1], tmp[300000 + 1];
int n;
long long ans = 0;
void dfs(ci u, ci p = 0) {
  int x = 0;
  for (int i = g.head[u], v; i; i = g.edge[i].nxt)
    if ((v = g.edge[i].v) != p) {
      dfs(v, u);
      maxify(x, dp3[v]);
    }
  ans += dp3[u] = x + 1;
  int* cnt = son;
  for (int i = g.head[u], v; i; i = g.edge[i].nxt)
    if ((v = g.edge[i].v) != p) *++cnt = v;
  dp1[u][1] = dp2[u][1] = n;
  if (cnt == son) {
    ans += n - 1;
    memset(dp1[0] + 1, 0, ((20 - 1) << 2));
    memset(dp2[0] + 1, 0, ((20 - 1) << 2));
    return;
  }
  for (int k = 1, *i, *tp, kk = 1; k < 20;
       k = kk, maxify(dp2[u][kk], dp1[u][kk] = tp - i)) {
    tp = tmp, ++kk;
    for (int *i = son, &t = dp2[u][kk]; ++i <= cnt;
         *++tp = dp1[*i][k], maxify(t, dp2[*i][kk]))
      ;
    sort(tmp + 1, tp + 1), i = tp;
    for (int* x = tp + 1; i > tmp && x - i <= *i; --i)
      ;
  }
  for (int k = 1; k < 20; ++k) {
    int x = dp2[u][k], y = dp2[u][k + 1];
    if (!y) y = 1;
    ans += k * (long long)(x - y);
    if (y == 1) break;
  }
}
int main() {
  scanf("%d", &n), g.build();
  for (int i = n, u, v; --i; g.insert(u, v)) scanf("%d%d", &u, &v);
  dfs(1);
  printf("%lld\n", ans);
  return 0;
}
