#include <bits/stdc++.h>
using namespace std;
const int NMAX = 3e5 + 10, LGMAX = 19;
int N;
int MaxLevel;
int level[NMAX], height[NMAX];
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;
}
void iterativeDFS(int node) {
  stack<pair<int, int>> S;
  father[node] = -1;
  LevelNodes[0].push_back(node);
  S.push({node, 0});
  while (!S.empty()) {
    int node, i;
    tie(node, i) = S.top();
    if (i == 0) {
      height[node] = 1;
      if (father[node] != -1 && T[node].size() == 1) {
        ++answer;
        S.pop();
        continue;
      }
    }
    if (i < (int)T[node].size()) {
      S.top().second = i + 1;
      if (T[node][i] == father[node]) continue;
      ++DP[2][node];
      father[T[node][i]] = node;
      level[T[node][i]] = level[node] + 1;
      MaxLevel = max(MaxLevel, level[node] + 1);
      LevelNodes[level[node] + 1].push_back(T[node][i]);
      S.push({T[node][i], 0});
    } else if (i == (int)T[node].size()) {
      S.pop();
      GoUp[DP[2][node]].push_back({2, node});
      for (int next : T[node]) {
        if (next != father[node]) {
          height[node] = max(height[node], 1 + height[next]);
        }
      }
      answer += height[node];
    }
  }
}
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);
  }
  iterativeDFS(1);
  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;
}
