#include <bits/stdc++.h>
std::vector<int> node[524288];
int mk[524288][32], km[524288][32];
int dpmk[524288][32], dpkm[524288][32];
long long int ans;
int a[524288];
int na;
int n, k, m;
void dfs(int p, int u) {
  0;
  for (auto v : node[u])
    if (v != p) dfs(u, v);
  for (int i = 1; i < k; ++i) {
    na = 0;
    for (auto v : node[u])
      if (v != p) a[na++] = mk[v][i];
    if (na >= i) {
      std::nth_element(a, a + na - i, a + na);
      dpmk[u][i] = mk[u][i] = a[na - i] + 1;
    } else
      dpmk[u][i] = mk[u][i] = 1;
    for (auto v : node[u])
      if (v != p) dpmk[u][i] = std::max(dpmk[u][i], dpmk[v][i]);
    ans += dpmk[u][i];
    0;
  }
  dpkm[u][1] = km[u][1] = n;
  ans += n - (k - 1);
  for (int i = 2; i < m; ++i) {
    na = 0;
    for (auto v : node[u])
      if (v != p) a[na++] = km[v][i - 1];
    std::sort(a, a + na);
    km[u][i] = 0;
    for (int j = 1; j <= na; ++j)
      if (a[na - j] >= j) km[u][i] = j;
    dpkm[u][i] = km[u][i];
    for (auto v : node[u])
      if (v != p) dpkm[u][i] = std::max(dpkm[u][i], dpkm[v][i]);
    ans += std::max(0, dpkm[u][i] - (k - 1));
    0;
  }
}
int main() {
  scanf("%d", &n), k = std::min(n + 1, 32), m = std::min(n + 1, 32);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
    node[v].push_back(u);
  }
  dfs(1, 1);
  printf("%lld\n", ans);
  return 0;
}
