#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
vector<int> e[N];
int d[N], q[N], n;
int f[N][20];
long long sum;
void dfs(int x, int fa) {
  for (auto i : e[x])
    if (i != fa) {
      dfs(i, x);
      d[x] = max(d[x], d[i]);
    }
  d[x]++;
  sum += d[x];
  f[x][1] = n;
  for (int j = (int)(2); j <= (int)(18); j++) {
    *q = 0;
    for (auto i : e[x])
      if (i != fa) q[++*q] = f[i][j - 1];
    sort(q + 1, q + *q + 1);
    reverse(q + 1, q + *q + 1);
    int p = 0;
    for (; p != *q && q[p + 1] >= p + 1; ++p)
      ;
    f[x][j] = p;
  }
}
void solve(int x, int fa) {
  for (auto i : e[x])
    if (i != fa) {
      solve(i, x);
      for (int j = (int)(1); j <= (int)(18); j++)
        f[x][j] = max(f[x][j], f[i][j]);
    }
  for (int j = (int)(1); j <= (int)(18); j++)
    if (f[x][j] >= 1) sum += f[x][j] - 1;
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 0);
  solve(1, 0);
  printf("%lld\n", sum);
}
