#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * inf;
const int N = 300000 + 7;
const int M = 19;
const int multipleTest = 0;
vector<int> adj[N];
int n;
long long ans = 0;
int maxLen[N];
int maxK[N][M];
int maxP[N][M];
bool check(int u, int len, int k, int r) {
  int cnt = 0;
  for (int v : adj[u])
    if (v != r) {
      if (maxK[v][len - 1] >= k) ++cnt;
    }
  return cnt >= k;
}
void dfs(int u, int r) {
  maxLen[u] = 1;
  for (int v : adj[u])
    if (v != r) {
      dfs(v, u);
      maxLen[u] = max(maxLen[v] + 1, maxLen[u]);
    }
  ans += maxLen[u];
  for (int len = M - 1; len > 1; --len) {
    int lo = (len == M - 1) ? 2 : maxK[u][len + 1] + 1;
    int hi = n;
    int res = lo - 1;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      if (check(u, len, mid, r)) {
        res = mid;
        lo = mid + 1;
      } else
        hi = mid - 1;
    }
    maxK[u][len] = res;
  }
  maxK[u][1] = n;
  for (int len = M - 1; len > 0; --len) maxP[u][len] = maxK[u][len];
  for (int len = M - 1; len > 0; --len) {
    for (int v : adj[u])
      if (v != r) {
        maxP[u][len] = max(maxP[u][len], maxP[v][len]);
      }
    if (len == M - 1)
      ans += (maxP[u][len] - 1) * len;
    else
      ans += (maxP[u][len] - maxP[u][len + 1]) * len;
  }
}
void solve() {
  cin >> n;
  for (int i = (1), _b = (n); i < _b; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, -1);
  cout << ans << '\n';
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}
