#include <bits/stdc++.h>
using namespace std;
struct EDGE {
  int to, next;
} e[600010];
int n, head[300010], top;
void add(int u, int v) {
  e[top].to = v;
  e[top].next = head[u];
  head[u] = top++;
}
int dp[300010][20], fa[300010], dep[300010];
void dfs(int x) {
  dp[x][1] = n;
  int i, j;
  for (i = head[x]; ~i; i = e[i].next) {
    if (e[i].to == fa[x]) continue;
    fa[e[i].to] = x;
    dfs(e[i].to);
    dep[x] = max(dep[x], dep[e[i].to]);
  }
  dep[x]++;
  vector<int> v;
  for (j = 2; j < 20; j++) {
    v.push_back(-1);
    for (i = head[x]; ~i; i = e[i].next) {
      if (e[i].to == fa[x]) continue;
      v.push_back(dp[e[i].to][j - 1]);
    }
    sort(v.begin() + 1, v.end(), greater<int>());
    for (i = 1; i < v.size(); i++) {
      if (v[i] >= i)
        dp[x][j] = i;
      else
        break;
    }
    v.clear();
  }
}
void dfs1(int x) {
  int i, j;
  for (i = head[x]; ~i; i = e[i].next) {
    if (e[i].to == fa[x]) continue;
    dfs1(e[i].to);
    for (j = 1; j < 20; j++) dp[x][j] = max(dp[x][j], dp[e[i].to][j]);
  }
}
int main() {
  memset(head, 255, sizeof(head));
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  int i, u, v;
  for (i = 1; i < n; i++) cin >> u >> v, add(u, v), add(v, u);
  dfs(1);
  dfs1(1);
  long long ans = 0;
  int j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j < 20; j++) {
      ans += max(dp[i][j] - 1, 0);
    }
    ans += dep[i];
  }
  cout << ans << '\n';
  return 0;
}
