#include <bits/stdc++.h>
using namespace std;
template <typename T>
void in(T &x) {
  T c = getchar();
  while (((c < 48) || (c > 57)) && (c != '-')) c = getchar();
  bool neg = false;
  if (c == '-') neg = true;
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x * 10) + (c - 48);
  if (neg) x = -x;
}
const int MAXN = 3e5 + 10;
int n;
vector<int> adj[MAXN];
vector<vector<int> > values[MAXN];
vector<int> dp[MAXN];
int sub[MAXN];
void walk(int r, int p) {
  values[r].resize(adj[r].size() + 1);
  sub[r] = 1;
  int sons = 0;
  for (int c : adj[r]) {
    if (c == p) continue;
    walk(c, r), sons++;
    sub[r] += sub[c];
  }
  dp[r].resize(sons + 1);
  for (int i = 1; i < dp[r].size(); i++) {
    if (values[r][i].size() >= i) {
      sort(values[r][i].begin(), values[r][i].end(), greater<int>());
      dp[r][i] = values[r][i][i - 1] + 1;
    } else
      dp[r][i] = 2;
    if (p != -1 and values[p].size() > i) values[p][i].push_back(dp[r][i]);
  }
}
set<pair<int, int> > data[MAXN];
long long ans = 0, curr = 0;
bool big[MAXN];
void add(int r, int p) {
  for (int k = 1; k < dp[r].size(); k++) {
    curr -= data[k].rbegin()->first;
    data[k].insert({dp[r][k], r});
    curr += data[k].rbegin()->first;
  }
  for (int c : adj[r]) {
    if (c != p and big[c] == false) {
      add(c, r);
    }
  }
}
void rem(int r, int p) {
  for (int k = 1; k < dp[r].size(); k++) {
    curr -= data[k].rbegin()->first;
    data[k].erase({dp[r][k], r});
    curr += data[k].rbegin()->first;
  }
  for (int c : adj[r]) {
    if (c != p) {
      rem(c, r);
    }
  }
}
void go(int r, int p, bool keep) {
  int maxim = 0, bc = -1, sons = 0;
  for (int c : adj[r]) {
    if (c != p) {
      if (maxim < sub[c]) maxim = sub[c], bc = c;
      sons++;
    }
  }
  if (bc != -1) big[bc] = true;
  for (int c : adj[r]) {
    if (c != p and big[c] == false) {
      go(c, r, false);
    }
  }
  if (bc != -1) go(bc, r, true);
  add(r, p);
  ans += curr;
  if (bc != -1) big[bc] = false;
  if (!keep) rem(r, p);
}
int main() {
  int a, b;
  in(n);
  for (int i = 1; i < n; i++) {
    in(a), in(b);
    adj[a].push_back(b), adj[b].push_back(a);
  }
  walk(1, -1);
  for (int i = 1; i <= n; i++) {
    data[i].insert({1, -1});
  }
  curr = n;
  go(1, -1, true);
  printf("%lld\n", ans);
  return 0;
}
