#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
template <typename T>
bool cmax(T &a, T b) {
  return (a < b) ? a = b, 1 : 0;
}
template <typename T>
bool cmin(T &a, T b) {
  return (a > b) ? a = b, 1 : 0;
}
template <typename T>
T read() {
  T ans = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (isdigit(ch))
    ans = (ans << 3) + (ans << 1) + (ch - '0'), ch = getchar();
  return ans * f;
}
template <typename T>
void write(T x, char y) {
  if (x == 0) {
    putchar('0'), putchar(y);
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  static char wr[20];
  int top = 0;
  for (; x; x /= 10) wr[++top] = x % 10 + '0';
  while (top) putchar(wr[top--]);
  putchar(y);
}
void file() {}
int n;
vector<int> E[N];
void input() {
  int x, y;
  n = read<int>();
  for (register int i = (int)(2); i <= (int)(n); ++i) {
    x = read<int>(), y = read<int>();
    E[x].push_back(y), E[y].push_back(x);
  }
}
const int inf = 0x3f3f3f3f;
const int M = 20;
int dp[N][21];
long long ans;
int q[N], top;
void DP(int u, int pre) {
  dp[u][1] = n;
  for (int v : E[u])
    if (v ^ pre) DP(v, u);
  dp[u][1] = n;
  for (register int i = (int)(2); i <= (int)(M - 1); ++i) {
    top = 0;
    for (int v : E[u])
      if (v ^ pre) q[++top] = dp[v][i - 1];
    sort(q + 1, q + top + 1);
    dp[u][i] = 0;
    for (register int k = (int)(top); k >= (int)(1); --k)
      if (q[top - k + 1] >= k) {
        dp[u][i] = k;
        break;
      }
  }
}
int num[N];
void dfs(int u, int pre) {
  num[u] = 1;
  for (int v : E[u])
    if (v ^ pre) {
      dfs(v, u);
      cmax(num[u], num[v] + 1);
      for (register int i = (int)(1); i <= (int)(M - 1); ++i)
        cmax(dp[u][i], dp[v][i]);
    }
}
void work() {
  DP(1, 0);
  dfs(1, 0);
  for (register int i = (int)(1); i <= (int)(n); ++i) ans += num[i];
  for (register int i = (int)(1); i <= (int)(n); ++i)
    for (register int j = (int)(1); j <= (int)(M - 1); ++j) {
      if (dp[i][j]) ans += dp[i][j] - 1;
    }
  write(ans, '\n');
}
int main() {
  file();
  input();
  work();
  return 0;
}
