#include <bits/stdc++.h>
using namespace std;
int n, x, y, dep[300010], v[300010 * 2], nxt[300010 * 2], h[300010], ec,
    f[300010][30], a[300010], g[300010], fa[300010];
long long r;
struct no {
  int x, y;
};
vector<no> vc[300010];
void add(int x, int y) {
  v[++ec] = y;
  nxt[ec] = h[x];
  h[x] = ec;
}
int cp(int x, int y) { return x > y; }
void dp(int x) {
  dep[x] = 1;
  f[x][1] = n;
  for (int i = h[x]; i; i = nxt[i])
    if (v[i] != fa[x]) {
      fa[v[i]] = x;
      dp(v[i]);
      dep[x] = max(dep[x], dep[v[i]] + 1);
    }
  r += dep[x];
  for (int i = 2; i < 20; i++) {
    int k = 0, ct = 0;
    for (int j = h[x]; j; j = nxt[j])
      if (v[j] != fa[x]) a[++ct] = f[v[j]][i - 1];
    if (!ct) break;
    sort(a + 1, a + ct + 1, cp);
    while (k < ct && a[k + 1] > k) k++;
    f[x][i] = k;
    vc[k].push_back((no){x, i});
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dp(1);
  long long s = n;
  for (int i = 1; i <= n; i++) g[i] = 1;
  for (int k = n; k > 1; k--) {
    for (auto x : vc[k]) {
      int a = x.x, b = x.y;
      while (a && g[a] < b) {
        s += b - g[a];
        g[a] = b;
        a = fa[a];
      }
    }
    r += s;
  }
  cout << r;
}
