#include <bits/stdc++.h>
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0;
  int op = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') op = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return x * op;
}
int n, cnt, head[300005], mx[300005], dp[300005][25], q[300005];
long long ans;
struct edge {
  int to, nxt;
} e[300005 << 1];
void adde(int x, int y) {
  e[++cnt].to = y;
  e[cnt].nxt = head[x];
  head[x] = cnt;
}
void ins(int x, int y) {
  adde(x, y);
  adde(y, x);
}
const bool cmp(const int x, const int y) { return x > y; }
void dfs(int u, int pr) {
  for (int i = head[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != pr) {
      dfs(v, u);
      mx[u] = max(mx[u], mx[v]);
    }
  ans += ++mx[u];
  dp[u][1] = n;
  for (int i = (2); i <= (20); i++) {
    int tp = 0;
    for (int j = head[u], v; j; j = e[j].nxt)
      if ((v = e[j].to) != pr) q[++tp] = dp[v][i - 1];
    sort(q + 1, q + 1 + tp, cmp);
    for (int j = (tp); j >= (2); j--)
      if (q[j] >= j) {
        dp[u][i] = j;
        break;
      }
  }
}
void solve(int u, int pr) {
  for (int i = head[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != pr) {
      solve(v, u);
      for (int j = (1); j <= (20); j++) dp[u][j] = max(dp[u][j], dp[v][j]);
    }
  for (int i = (1); i <= (20); i++) {
    ans += (long long)(dp[u][i] - dp[u][i + 1]) * i;
    if (dp[u][i + 1] == 0) {
      ans -= i;
      break;
    }
  }
}
int main() {
  n = read();
  for (int i = (1); i <= (n - 1); i++) {
    int x = read(), y = read();
    ins(x, y);
  }
  dfs(1, 0);
  solve(1, 0);
  cout << ans << endl;
  return 0;
}
