#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n;
vector<int> adj[N];
vector<int> karr[N];
multiset<int> ss[N];
vector<int> *val[N];
long long *sum[N];
long long ans = 0;
void dfs(int v, int p) {
  int c = adj[v].size() - (p > 0);
  for (auto it : adj[v]) {
    if (it == p) continue;
    dfs(it, v);
  }
  val[v] = new vector<int>(c, 0);
  sum[v] = new long long(0);
  for (auto it : adj[v]) {
    if (it == p) continue;
    for (int i = 0; i < (int)karr[it].size() && i < c; i++) {
      ss[i].insert(karr[it][i]);
      if ((int)ss[i].size() > i + 1) {
        ss[i].erase(ss[i].begin());
      }
    }
    if (val[v]->size() < val[it]->size()) {
      swap(val[v], val[it]);
      swap(sum[v], sum[it]);
    }
    for (int i = 0; i < (int)val[it]->size(); i++) {
      if ((*val[it])[i] > (*val[v])[i]) {
        (*sum[v]) += (*val[it])[i] - (*val[v])[i];
        (*val[v])[i] = (*val[it])[i];
      }
    }
  }
  for (int i = 1; i <= c; i++) {
    int cnt = 0;
    if ((int)ss[i - 1].size() == i) {
      cnt = 1 + (*ss[i - 1].begin());
    } else
      cnt = 2;
    karr[v].push_back(cnt);
    ss[i - 1].clear();
    if (cnt > (*val[v])[i - 1]) {
      (*sum[v]) += cnt - (*val[v])[i - 1];
      (*val[v])[i - 1] = cnt;
    }
  }
  ans += (*sum[v]);
  ans += n - val[v]->size();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0);
  cout << ans << "\n";
  return 0;
}
