#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
bool cmax(T& a, const U& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T, class U>
bool cmin(T& a, const U& b) {
  return b < a ? a = b, 1 : 0;
}
void _BG(const char* s) { cerr << s << endl; };
template <class T, class... TT>
void _BG(const char* s, T a, TT... b) {
  for (int c = 0; *s && (c || *s != ','); ++s) {
    cerr << *s;
    for (char x : "([{") c += *s == x;
    for (char x : ")]}") c -= *s == x;
  }
  cerr << " = " << a;
  if (sizeof...(b)) {
    cerr << ", ";
    ++s;
  }
  _BG(s, b...);
}
bool RD() { return 1; }
bool RD(char& a) { return scanf(" %c", &a) == 1; }
bool RD(char* a) { return scanf("%s", a) == 1; }
bool RD(double& a) { return scanf("%lf", &a) == 1; }
bool RD(int& a) { return scanf("%d", &a) == 1; }
bool RD(long long& a) { return scanf("%lld", &a) == 1; }
template <class T, class... TT>
bool RD(T& a, TT&... b) {
  return RD(a) && RD(b...);
}
void PT(const char& a) { putchar(a); }
void PT(char const* const& a) { fputs(a, stdout); }
void PT(const double& a) { printf("%.16f", a); }
void PT(const int& a) { printf("%d", a); }
void PT(const long long& a) { printf("%lld", a); }
template <char s = ' ', char e = '\n'>
void PL() {
  if (e) PT(e);
}
template <char s = ' ', char e = '\n', class T, class... TT>
void PL(const T& a, const TT&... b) {
  PT(a);
  if (sizeof...(b) && s) PT(s);
  PL<s, e>(b...);
}
const int N = 3e5 + 87;
int n;
struct dp {
  vector<int> v;
  long long s;
  void upd(int i, int x) {
    if (((int)(v).size()) <= i) v.resize(i + 1);
    int y = max(v[i], x);
    s += y - v[i];
    v[i] = y;
  }
  void join(dp& x) {
    if (x.v.size() > v.size()) {
      s = x.s;
      v.swap(x.v);
    }
    for (int i(0); i < (((int)(x.v).size())); ++i) upd(i, x.v[i]);
  }
  long long sum() { return s + n - ((int)(v).size()); }
  void dbg(int u) {
    for (int i(0); i < (((int)(v).size())); ++i)
      cerr << "dp[" << i + 1 << "][" << u << "]=" << v[i] << endl;
    for (int i(((int)(v).size())); i < (n); ++i)
      cerr << "dp[" << i + 1 << "][" << u << "]=" << 1 << endl;
  }
} d[N];
vector<int> g[N], ans[N];
long long dfs(int p, int u) {
  int k = ((int)(g[u]).size()) + (p ? -1 : 0);
  vector<priority_queue<int, vector<int>, greater<int>>> pq(k);
  long long sum = 0;
  for (int v : g[u])
    if (v != p) {
      sum += dfs(u, v);
      d[u].join(d[v]);
      for (int i(0); i < (min(k, ((int)(ans[v]).size()))); ++i) {
        pq[i].push(ans[v][i]);
        if (((int)(pq[i]).size()) == i + 2) pq[i].pop();
      }
    }
  ans[u].resize(k);
  for (int i(0); i < (k); ++i)
    d[u].upd(i,
             ans[u][i] = ((int)(pq[i]).size()) == i + 1 ? pq[i].top() + 1 : 2);
  return sum + d[u].sum();
}
int main() {
  RD(n);
  for (int __i(0); __i < (n - 1); ++__i) {
    int u, v;
    RD(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  PL(dfs(0, 1));
}
