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 NMAX = 3e5 + 10, LGMAX = 19;
int N;
int MaxLevel;
int64_t answer;
int DP[LGMAX][NMAX], father[NMAX], val[NMAX];
vector<int> T[NMAX], LevelNodes[NMAX];
vector<pair<int, int>> GoUp[NMAX];
int DFS(int node, int from, int level) {
  father[node] = from;
  MaxLevel = max(MaxLevel, level);
  LevelNodes[level].push_back(node);
  if (from != -1 && T[node].size() == 1) {
    ++answer;
    return 1;
  }
  int height = 1;
  for (int next : T[node]) {
    if (next == from) continue;
    ++DP[2][node];
    height = max(height, 1 + DFS(next, node, level + 1));
  }
  GoUp[DP[2][node]].push_back({2, node});
  answer += height;
  return height;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N - 1; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    T[x].push_back(y);
    T[y].push_back(x);
  }
  DFS(1, -1, 0);
  for (int i = 3; i < LGMAX; ++i) {
    for (int j = MaxLevel; j >= 0; --j) {
      for (int node : LevelNodes[j]) {
        vector<int> values;
        for (int next : T[node]) {
          if (next == father[node]) continue;
          values.push_back(DP[i - 1][next]);
        }
        sort(values.begin(), values.end(), greater<int>());
        int k = 0;
        while (k < (int)values.size() && k + 1 <= values[k]) ++k;
        if (k > 0 && k <= values[k - 1]) {
          DP[i][node] = k;
          GoUp[DP[i][node]].push_back({i, node});
        }
      }
    }
  }
  int64_t value = N;
  for (int i = 1; i <= N; ++i) val[i] = 1;
  for (int i = N; i >= 2; --i) {
    for (auto det : GoUp[i]) {
      int depth = det.first;
      int node = det.second;
      while (node != -1 && depth > val[node]) {
        value += depth - val[node];
        val[node] = depth;
        node = father[node];
      }
    }
    answer += value;
  }
  cout << answer << '\n';
  return 0;
}
