#include <bits/stdc++.h>
using std::make_pair;
using std::max;
using std::pair;
using std::vector;
const int w = 20, N = 300005;
int to[N << 1], edge, last[N], Next[N << 1], dp[N][w], b[N], n, x, y, f[N],
    g[N];
long long ans, sum;
vector<pair<int, int> > v[N];
void add(int x, int y) {
  to[++edge] = y;
  Next[edge] = last[x];
  last[x] = edge;
}
int dfs(int x, int fa) {
  f[x] = fa;
  int dep = 0;
  for (int i = last[x]; i; i = Next[i])
    if (to[i] != fa) dep = max(dep, dfs(to[i], x)), dp[x][2]++;
  for (int d = 2; d < w; d++) {
    int cnt = 0;
    for (int i = last[x]; i; i = Next[i]) {
      if (to[i] != fa) b[++cnt] = dp[to[i]][d];
    }
    std::sort(b + 1, b + cnt + 1);
    std::reverse(b + 1, b + cnt + 1);
    for (int i = 1; i <= cnt && b[i] >= i; i++) dp[x][d + 1]++;
    if (dp[x][d + 1]) v[dp[x][d + 1]].push_back(make_pair(x, d + 1));
  }
  if (dp[x][2]) v[dp[x][2]].push_back(make_pair(x, 2));
  dep += 1;
  ans += dep;
  return dep;
}
void upd(int x, int y) {
  if (g[x] >= y) return;
  sum += y - g[x];
  g[x] = y;
  if (f[x]) upd(f[x], y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  dfs(1, 0);
  sum = n;
  for (int i = 1; i <= n; i++) g[i] = 1;
  for (int k = n; k >= 2; k--) {
    for (auto j : v[k]) upd(j.first, j.second);
    ans += sum;
  }
  printf("%lld\n", ans);
}
