#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 99;
struct edge {
  int to, nxt;
} e[maxn << 1];
int head[maxn], tot;
void add(int x, int y) {
  e[++tot].to = y;
  e[tot].nxt = head[x];
  head[x] = tot;
}
int f[maxn][30], b[maxn], n, siz, top, stac[maxn], g[maxn], fa[maxn];
long long ans = 0;
vector<pair<int, int> > h[maxn];
void dp(int x) {
  g[x] = 1;
  f[x][1] = n;
  for (int i = head[x]; i; i = e[i].nxt) {
    int y = e[i].to;
    if (y == fa[x]) continue;
    fa[y] = x;
    dp(y);
    g[x] = max(g[x], g[y] + 1);
  }
  ans += g[x];
  for (int j = 2; j < 30; j++) {
    top = 0;
    for (int i = head[x]; i; i = e[i].nxt) {
      int y = e[i].to;
      if (y == fa[x]) continue;
      stac[++top] = f[y][j - 1];
    }
    sort(stac + 1, stac + 1 + top, greater<int>());
    for (int i = top; i; i--)
      if (stac[i] >= i) {
        f[x][j] = i;
        break;
      }
    h[f[x][j]].push_back(make_pair(x, j));
  }
}
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);
  }
  dp(1);
  long long sum = n;
  for (int i = 1; i <= n; i++) g[i] = 1;
  for (int k = n; k > 1; k--) {
    for (int i = 0; i < h[k].size(); i++) {
      int x = h[k][i].first, now = h[k][i].second;
      while (x) {
        if (now < g[x]) break;
        sum += now - g[x];
        g[x] = now;
        x = fa[x];
      }
    }
    ans += sum;
  }
  cout << ans;
}
