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;
long long n, fh[300069], dp[300069][18], z;
vector<long long> al[300069];
bitset<300069> vtd;
void bd(long long x) {
  long long i, j, sz = al[x].size(), l, lh, rh, md, zz, c;
  vector<long long> v;
  vtd[x] = 1;
  for (i = 0; i < sz; i++) {
    l = al[x][i];
    if (!vtd[l]) {
      bd(l);
      fh[x] = max(fh[x], fh[l] + 1);
      v.push_back(l);
    }
  }
  sz = v.size();
  dp[x][0] = n;
  for (i = 1; i < 18; i++) {
    for (lh = 0, rh = n; lh <= rh;) {
      md = (lh + rh) / 2;
      c = 0;
      for (j = 0; j < sz; j++) {
        l = v[j];
        c += md <= dp[l][i - 1];
      }
      if (c >= md) {
        zz = md;
        lh = md + 1;
      } else {
        rh = md - 1;
      }
    }
    dp[x][i] = zz;
  }
  z += fh[x];
}
void bd2(long long x) {
  long long i, j, sz = al[x].size(), l;
  vtd[x] = 1;
  for (i = 0; i < sz; i++) {
    l = al[x][i];
    if (!vtd[l]) {
      bd2(l);
      for (j = 0; j < 18; j++) {
        dp[x][j] = max(dp[x][j], dp[l][j]);
      }
    }
  }
  l = 1;
  for (i = 17; i + 1; i--) {
    z += max(dp[x][i] - l, 0ll) * i;
    l = max(l, dp[x][i]);
  }
}
int main() {
  long long i, k, l;
  scanf("%lld", &n);
  for (i = 0; i < n - 1; i++) {
    scanf("%lld%lld", &k, &l);
    al[k].push_back(l);
    al[l].push_back(k);
  }
  z = n * n;
  bd(1);
  vtd.reset();
  bd2(1);
  printf("%lld\n", z);
}
