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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(int a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(int a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  write(a);
  puts("");
}
const int N = 300005, K = 20;
long long ans;
int n, tp[N], q[N], dp[N][K];
vector<int> v[N];
inline bool cmp(int a, int b) { return a > b; }
void dfs(int p, int fa) {
  for (unsigned i = 0; i < v[p].size(); i++)
    if (v[p][i] != fa) {
      dfs(v[p][i], p);
      tp[p] = max(tp[v[p][i]], tp[p]);
    }
  ans += ++tp[p];
  dp[p][1] = n;
  for (int i = 2; i < K; i++) {
    int tot = 0;
    for (unsigned j = 0; j < v[p].size(); j++)
      if (dp[v[p][j]][i - 1] > 1) q[++tot] = dp[v[p][j]][i - 1];
    sort(&q[1], &q[tot + 1], cmp);
    for (int j = tot; j > 1; j--) {
      if (q[j] >= j) {
        dp[p][i] = j;
        break;
      }
    }
  }
}
void solve(int p, int fa) {
  for (unsigned i = 0; i < v[p].size(); i++)
    if (v[p][i] != fa) {
      solve(v[p][i], p);
      for (int j = 0; j < K; j++) dp[p][j] = max(dp[p][j], dp[v[p][i]][j]);
    }
  for (int i = 1; i < K - 1; i++) {
    ans += ((long long)dp[p][i] - dp[p][i + 1]) * i;
    if (dp[p][i + 1] == 0) {
      ans -= i;
      break;
    }
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int s = read(), t = read();
    v[s].push_back(t);
    v[t].push_back(s);
  }
  dfs(1, 0);
  solve(1, 0);
  cout << ans << endl;
}
