#include <bits/stdc++.h>
using namespace std;
bool home = 1;
signed realMain();
signed main() {
  home = 0;
  if (home) {
    freopen("input", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
const long long N = (long long)3e5 + 7;
const long long M = 20;
long long n, dep[N], ret, dp[N][M], down[N];
vector<long long> g[N];
void build(long long a) {
  down[a] = 1;
  vector<long long> kids;
  for (auto &b : g[a]) {
    if (dep[b]) continue;
    kids.push_back(b);
    dep[b] = 1 + dep[a];
    build(b);
    down[a] = max(down[a], 1 + down[b]);
  }
  g[a] = kids;
  for (long long j = 0; j < M; j++) dp[a][j] = -1;
}
void dfs(long long a) {
  dp[a][1] = n;
  for (auto &b : g[a]) dfs(b);
  for (long long h = 2; h < M; h++) {
    vector<long long> lol;
    for (auto &b : g[a]) {
      lol.push_back(dp[b][h - 1]);
    }
    sort(lol.rbegin(), lol.rend());
    for (long long k = 1; k <= (long long)g[a].size(); k++) {
      if (k <= lol[k - 1]) {
        dp[a][h] = k;
      }
    }
  }
}
void dfs2(long long a) {
  for (auto &b : g[a]) {
    dfs2(b);
    for (long long h = 1; h < M; h++) {
      dp[a][h] = max(dp[a][h], dp[b][h]);
    }
  }
}
signed realMain() {
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dep[1] = 1;
  build(1);
  for (long long i = 1; i <= n; i++) {
    ret += down[i];
  }
  dfs(1);
  dfs2(1);
  for (long long i = 1; i <= n; i++) {
    long long last = 1;
    for (long long h = M - 1; h >= 1; h--) {
      if (dp[i][h] != -1) {
        ret += (dp[i][h] - last) * h;
        last = dp[i][h];
      }
    }
  }
  cout << ret << "\n";
  return 0;
}
