#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> vec[300005];
int niche[300005];
int nije[300005][21], dp[300005][21];
long long ans;
void dfs(int s, int p = 0) {
  niche[s] = 1;
  for (int v : vec[s]) {
    if (v == p) continue;
    dfs(v, s);
    niche[s] = max(niche[s], niche[v] + 1);
  }
  nije[s][1] = dp[s][1] = n;
  for (int i = 2; i < 21; i++) {
    vector<int> tmp;
    for (int v : vec[s]) {
      if (v == p) continue;
      tmp.push_back(nije[v][i - 1]);
    }
    sort(tmp.begin(), tmp.end(), greater<int>());
    for (int j = 0; j < tmp.size(); j++) {
      if (tmp[j] >= j + 1) nije[s][i] = j + 1;
    }
    dp[s][i] = nije[s][i];
    for (int v : vec[s]) {
      if (v == p) continue;
      dp[s][i] = max(dp[s][i], dp[v][i]);
    }
  }
  for (int i = 2; i < 21; i++) ans += (i - 1) * (dp[s][i - 1] - dp[s][i]);
  if (dp[s][21 - 1]) ans += niche[s];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  dfs(1);
  printf("%lld\n", ans);
  return 0;
}
