#include <bits/stdc++.h>
using namespace std;
const long long N = 300005;
long long n, dp[N][20][2], ans, h[N];
vector<vector<long long> > gr;
priority_queue<long long> pq[N][20];
void dfs(long long u, long long par) {
  h[u] = 1;
  dp[u][1][0] = dp[u][1][1] = n;
  for (long long i = 0; i < gr[u].size(); ++i) {
    long long v = gr[u][i];
    if (v != par) {
      dfs(v, u);
      h[u] = max(h[u], h[v] + 1);
      for (long long j = 2; j <= 18; ++j) {
        pq[u][j].push(dp[v][j - 1][0]);
        dp[u][j][1] = max(dp[v][j][1], dp[u][j][1]);
      }
    }
  }
  vector<long long> x[20];
  for (long long i = 2; i <= 18; ++i) {
    while (!pq[u][i].empty()) {
      x[i].push_back(pq[u][i].top());
      pq[u][i].pop();
    }
  }
  for (long long i = 2; i <= 18; ++i) {
    if (x[i].size()) {
      for (long long j = x[i].size() - 1; j >= 0; --j) {
        if (x[i][j] >= j + 1) {
          dp[u][i][0] = max(j + 1, dp[u][i][0]);
          break;
        }
      }
      dp[u][i][1] = max(dp[u][i][1], dp[u][i][0]);
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  gr.resize(n + 5, vector<long long>());
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs(1, 0);
  for (long long i = 1; i <= n; ++i) ans += h[i];
  for (long long u = 1; u <= n; ++u) {
    for (long long i = 1; i <= 19; ++i) {
      long long l = 2;
      if (i <= 18) l = max(l, dp[u][i + 1][1] + 1);
      long long r = dp[u][i][1];
      if (l <= r) ans += (r - l + 1) * i;
    }
  }
  cout << ans;
  return 0;
}
