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;
int n;
vector<int> v[300007];
int lvl[300007];
int cnt[300007];
int f[300007][21];
int dp[300007][21];
long long ans = 0;
void dfs(int vertex, int prv) {
  int sz = v[vertex].size();
  lvl[vertex] = 1;
  for (int i = 0; i < sz; ++i) {
    int h = v[vertex][i];
    if (h == prv) {
      continue;
    }
    dfs(h, vertex);
    lvl[vertex] = max(lvl[vertex], lvl[h] + 1);
    for (int j = 1; j < 21; ++j) {
      dp[vertex][j] = max(dp[vertex][j], dp[h][j]);
    }
  }
  ans += lvl[vertex];
  f[vertex][1] = n;
  for (int j = 2; j < 21; ++j) {
    for (int i = 0; i < sz; ++i) {
      int h = v[vertex][i];
      if (h == prv) {
        continue;
      }
      if (f[h][j - 1] <= sz) {
        ++cnt[f[h][j - 1]];
      } else {
        ++cnt[sz];
      }
    }
    int suff = 0;
    for (int i = sz; i >= 0; --i) {
      suff += cnt[i];
      if (suff >= i) {
        f[vertex][j] = i;
        break;
      }
    }
    for (int i = 0; i <= sz; ++i) {
      cnt[i] = 0;
    }
  }
  int lst = 1;
  for (int j = 21 - 1; j >= 0; --j) {
    dp[vertex][j] = max(dp[vertex][j], f[vertex][j]);
    if (dp[vertex][j] > lst) {
      ans += 1LL * (dp[vertex][j] - lst) * j;
      lst = dp[vertex][j];
    }
  }
}
void input() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
}
void solve() {
  dfs(1, -1);
  printf("%I64d\n", ans);
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  solve();
  return 0;
}
