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 head[524288], last[1048576], to[1048576], cnt = 0;
void add(int u, int v) {
  cnt++;
  last[cnt] = head[u];
  head[u] = cnt;
  to[cnt] = v;
}
int dp[524288];
int a[524288];
long long answer = 0;
int n;
void dfs1(int u, int f, int k) {
  for (int i = head[u]; i; i = last[i]) {
    int v = to[i];
    if (v == f) {
      continue;
    }
    dfs1(v, u, k);
  }
  int cnt = 0;
  for (int i = head[u]; i; i = last[i]) {
    int v = to[i];
    if (v == f) {
      continue;
    }
    a[cnt] = dp[v];
    cnt++;
  }
  if (cnt < k) {
    dp[u] = 1;
    return;
  }
  sort(a, a + cnt);
  dp[u] = a[cnt - k] + 1;
}
int sol1(int u, int f) {
  int ans = dp[u];
  for (int i = head[u]; i; i = last[i]) {
    int v = to[i];
    if (v == f) {
      continue;
    }
    int ans2 = sol1(v, u);
    if (ans2 > ans) {
      ans = ans2;
    }
  }
  answer += ans;
  return ans;
}
void dfs2(int u, int f, int a) {
  if (a == 1) {
    dp[u] = n;
  } else {
    int l = 8, r = dp[u];
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      int cnt = 0;
      for (int i = head[u]; i; i = last[i]) {
        int v = to[i];
        if (v == f) {
          continue;
        }
        if (dp[v] >= mid) {
          cnt++;
        }
      }
      if (cnt >= mid) {
        l = mid;
      } else {
        r = mid - 1;
      }
    }
    dp[u] = l;
  }
  for (int i = head[u]; i; i = last[i]) {
    int v = to[i];
    if (v == f) {
      continue;
    }
    dfs2(v, u, a);
  }
}
int sol2(int u, int f) {
  int ans = dp[u];
  for (int i = head[u]; i; i = last[i]) {
    int v = to[i];
    if (v == f) {
      continue;
    }
    int ans2 = sol2(v, u);
    if (ans2 > ans) {
      ans = ans2;
    }
  }
  answer += ans - 8;
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  if (n <= 8) {
    for (int i = 1; i <= n; i++) {
      dfs1(1, 0, i);
      sol1(1, 0);
    }
    printf("%lld\n", answer);
    return 0;
  }
  for (int i = 1; i <= 8; i++) {
    dfs1(1, 0, i);
    sol1(1, 0);
  }
  for (int i = 1; i <= 8; i++) {
    dfs2(1, 0, i);
    sol2(1, 0);
  }
  printf("%lld\n", answer);
  return 0;
}
