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 gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 300000;
const int MAXDEP = 18;
int n;
vector<int> adj[MAXN];
int par[MAXN];
int top[MAXN], ntop;
void dfsinit(int at) {
  top[ntop++] = at;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par[at]) continue;
    par[to] = at;
    dfsinit(to);
  }
}
int jmx[MAXN];
int kmx[MAXN][MAXDEP + 1];
void dfsjmx(int at) {
  jmx[at] = 1;
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par[at]) continue;
    dfsjmx(to);
    jmx[at] = max(jmx[at], jmx[to] + 1);
  }
}
int cur[MAXN], ncur;
void dfskmx(int at) {
  for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
    int to = adj[at][i];
    if (to == par[at]) continue;
    dfskmx(to);
  }
  kmx[at][1] = n;
  for (int j = (2); j <= (MAXDEP); ++j) {
    ncur = 0;
    for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
      int to = adj[at][i];
      if (to != par[at]) cur[ncur++] = kmx[to][j - 1];
    }
    sort(cur, cur + ncur);
    reverse(cur, cur + ncur);
    kmx[at][j] = 0;
    for (int pos = (0); pos < (ncur); ++pos)
      if (cur[pos] >= pos + 1) kmx[at][j] = pos + 1;
  }
}
int dp[MAXN];
long long dpsum;
vector<pair<int, int> > e[MAXN + 1];
void upddp(int at, int val) {
  while (at != -1 && val > dp[at]) {
    dpsum += val - dp[at];
    dp[at] = val;
    at = par[at];
  }
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  par[0] = -1;
  ntop = 0;
  dfsinit(0);
  dfsjmx(0);
  dfskmx(0);
  long long ans = 0;
  for (int i = (0); i < (n); ++i) dp[i] = 0;
  dpsum = 0;
  for (int i = (0); i < (n); ++i)
    for (int j = (1); j <= (MAXDEP); ++j)
      if (kmx[i][j] >= 2) e[kmx[i][j]].push_back(make_pair(i, j));
  for (int k = n; k >= 2; --k) {
    for (int idx = (0); idx < (((int)(e[k]).size())); ++idx) {
      int i = e[k][idx].first, j = e[k][idx].second;
      upddp(i, j);
    }
    ans += dpsum;
  }
  for (int i = (0); i < (n); ++i) dp[i] = jmx[i];
  for (int i = n - 1; i >= 0; --i) {
    int at = top[i];
    ans += dp[at];
    if (par[at] != -1) dp[par[at]] = max(dp[par[at]], dp[at]);
  }
  printf("%lld\n", ans);
}
int main() {
  run();
  return 0;
}
