#include <bits/stdc++.h>
using namespace std;
long long ans;
int dp[300000 + 5][20], n;
vector<int> e[300000 + 5];
inline void upd(int &x, int y) {
  if (x < y) x = y;
}
int dfs(int now, int fa) {
  int mxdep = 0;
  for (auto v : e[now])
    if (v != fa) upd(mxdep, dfs(v, now));
  mxdep++;
  ans += mxdep;
  dp[now][1] = n;
  for (int m = 2; m <= 19; m++) {
    vector<int> tmp;
    for (auto v : e[now])
      if (v != fa) tmp.push_back(dp[v][m - 1]);
    sort(tmp.begin(), tmp.end(), greater<int>());
    int t = 1;
    while (t <= (int)tmp.size() && tmp[t - 1] >= t) t++;
    dp[now][m] = t - 1;
    upd(dp[now][m], 1);
  }
  return mxdep;
}
void dfs2(int now, int fa) {
  for (auto v : e[now])
    if (v != fa) {
      dfs2(v, now);
      for (int m = 1; m <= 19; m++) upd(dp[now][m], dp[v][m]);
    }
  for (int m = 1; m <= 18; m++) ans += 1ll * m * (dp[now][m] - dp[now][m + 1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 0);
  dfs2(1, 0);
  printf("%lld\n", ans);
  return 0;
}
