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 inf = 1e9 + 7;
const long long linf = 1ll * inf * inf;
const int N = 300000 + 7;
const int M = 20;
const int multipleTest = 0;
vector<int> adj[N];
int n;
long long ans = 0;
int maxLen[N];
int maxK[N][M];
int maxP[N][M];
bool check(int u, int len, int k, int r) {
  int cnt = 0;
  for (int v : adj[u])
    if (v != r) {
      if (maxK[v][len - 1] >= k) ++cnt;
    }
  return cnt >= k;
}
void dfs(int u, int r) {
  maxLen[u] = 1;
  for (int v : adj[u])
    if (v != r) {
      dfs(v, u);
      maxLen[u] = max(maxLen[v] + 1, maxLen[u]);
    }
  ans += maxLen[u];
  for (int len = M - 1; len > 1; --len) {
    int lo = (len == M - 1) ? 2 : maxK[u][len + 1] + 1;
    int hi = n;
    int res = lo - 1;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      if (check(u, len, mid, r)) {
        res = mid;
        lo = mid + 1;
      } else
        hi = mid - 1;
    }
    maxK[u][len] = res;
  }
  maxK[u][1] = n;
  for (int len = M - 1; len > 0; --len) maxP[u][len] = maxK[u][len];
  for (int len = M - 1; len > 0; --len) {
    for (int v : adj[u])
      if (v != r) {
        maxP[u][len] = max(maxP[u][len], maxP[v][len]);
      }
    if (len == M - 1)
      ans += (maxP[u][len] - 1) * len;
    else
      ans += (maxP[u][len] - maxP[u][len + 1]) * len;
  }
}
void solve() {
  cin >> n;
  for (int i = (1), _b = (n); i < _b; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, -1);
  cout << ans << '\n';
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}
