#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 2;
const long long inf = 1e9 + 7;
long long dp[N][22], f[N], max1[N][22];
long long ans = 0;
vector<long long> adj[N];
void dfs(long long x, long long p) {
  vector<long long> temp[22];
  long long i, j, lef, rig, mid;
  for (i = 0; i < adj[x].size(); i++) {
    if (adj[x][i] != p) {
      dfs(adj[x][i], x);
      f[x] = max(f[x], f[adj[x][i]] + 1);
      for (j = 1; j <= 20; j++) {
        if (dp[adj[x][i]][j - 1] != 0) {
          temp[j].push_back(dp[adj[x][i]][j - 1]);
        }
        max1[x][j] = max(max1[x][j], max1[adj[x][i]][j]);
      }
      dp[x][1]++;
    }
  }
  for (i = 2; i <= 20; i++) {
    sort(temp[i].begin(), temp[i].end(),
         [&](long long x, long long y) { return x > y; });
    rig = temp[i].size();
    lef = 1;
    while (rig > lef) {
      mid = (lef + rig + 1) / 2;
      if (temp[i][mid - 1] >= mid) {
        lef = mid;
      } else {
        rig = mid - 1;
      }
    }
    dp[x][i] = rig;
  }
  for (i = 1; i <= 20; i++) {
    max1[x][i] = max(max1[x][i], dp[x][i]);
  }
  for (i = 1; i <= 20; i++) {
    j = 2;
    if (i != 20) {
      j = max(j, max1[x][i + 1] + 1);
    }
    if (max1[x][i] >= j) {
      ans += (max1[x][i] - j + 1) * i;
    }
  }
  ans += f[x];
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, i, j, k, l;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    adj[j].push_back(k);
    adj[k].push_back(j);
  }
  dfs(1, 1);
  cout << ans + n * n;
}
