#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next;
} e[300005 * 2];
int head[300005], tot;
void add(int x, int y) {
  e[++tot] = (edge){y, head[x]};
  head[x] = tot;
}
int mx[300005], dp[300005][25], pp[300005][25];
long long ans;
int n, q[300005];
bool cmp(int x, int y) { return x > y; }
void dfs(int x, int fa) {
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != fa) {
      dfs(e[i].to, x);
      mx[x] = max(mx[x], mx[e[i].to]);
    }
  ++mx[x];
  ans += mx[x];
  dp[x][1] = pp[x][1] = n;
  for (int p = 2; p <= 20; p++) {
    int tp = 0;
    for (int i = head[x]; i; i = e[i].next)
      if (e[i].to != fa) q[++tp] = dp[e[i].to][p - 1];
    sort(q + 1, q + tp + 1, cmp);
    for (int j = tp; j >= 2; j--)
      if (q[j] >= j) {
        pp[x][p] = dp[x][p] = j;
        break;
      }
    for (int i = head[x]; i; i = e[i].next)
      if (e[i].to != fa) pp[x][p] = max(pp[e[i].to][p], pp[x][p]);
  }
  for (int i = 1; i <= 20; i++) {
    ans += 1ll * (pp[x][i] - pp[x][i + 1]) * i;
    if (pp[x][i + 1] == 0) {
      ans -= i;
      break;
    }
  }
}
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
