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>
namespace fuck {
const int N = 300100, M = 20;
int begin[N], next[N * 2], to[N * 2];
int n, e, lim;
void add(int x, int y, bool k = 1) {
  to[++e] = y;
  next[e] = begin[x];
  begin[x] = e;
  if (k) add(y, x, 0);
}
void initialize() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++) scanf("%d%d", &u, &v), add(u, v);
  lim = (int)std::sqrt(n);
  while (lim * lim + lim + 1 <= n) lim++;
}
std::vector<int> seq;
int f[N][M];
void dfs(int p = 1, int h = 0) {
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != h) dfs(q, p);
  f[p][1] = n;
  for (int dep = 2; dep < M; dep++) {
    seq.resize(0);
    for (int i = begin[p], q; i; i = next[i])
      if ((q = to[i]) != h) seq.push_back(f[q][dep - 1]);
    f[p][dep] = 0;
    std::sort(seq.begin(), seq.end());
    for (int k = seq.size(); k; k--)
      if (seq.end()[-k] >= k) {
        f[p][dep] = k;
        break;
      }
  }
}
void redfs(int p = 1, int h = 0) {
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != h) {
      redfs(q, p);
      for (int dep = 1; dep < M; dep++)
        f[p][dep] = std::max(f[p][dep], f[q][dep]);
    }
}
long long part1() {
  dfs(), redfs();
  long long ret = 0;
  for (int i = 1; i <= n; i++)
    for (int dep = 1; dep < M; dep++)
      if (f[i][dep] > 0) ret += f[i][dep] - 1;
  return ret;
}
int dep[N];
void depdfs(int p = 1, int h = 0) {
  dep[p] = 1;
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != h) depdfs(q, p), dep[p] = std::max(dep[p], dep[q] + 1);
}
long long part2() {
  depdfs();
  long long ret = 0;
  for (int i = 1; i <= n; i++) ret += dep[i];
  return ret;
}
void solve() {
  initialize();
  long long ans = part1() + part2();
  printf("%I64d\n", ans);
}
}  // namespace fuck
int main() {
  fuck::solve();
  return 0;
}
