#include <bits/stdc++.h>
using namespace std;
long long n;
vector<vector<long long> > egs;
vector<vector<long long> > boteg;
vector<vector<long long> > botegsort;
long long genbot(long long u, long long pr) {
  for (long long i = 0; i < ((long long((egs[u]).size()))); ++i) {
    if (egs[u][i] == pr) continue;
    long long tt = genbot(egs[u][i], u);
    boteg[u].push_back(tt);
    botegsort[u].push_back(tt);
  }
  sort((botegsort[u]).begin(), (botegsort[u]).end());
  reverse((botegsort[u]).begin(), (botegsort[u]).end());
  if (!botegsort[u].empty()) return botegsort[u][0] + 1;
  return 1;
}
long long sm;
void gentop(long long u, long long pr, long long gv) {
  if (gv) botegsort[u].push_back(gv);
  sort((botegsort[u]).begin(), (botegsort[u]).end());
  reverse((botegsort[u]).begin(), (botegsort[u]).end());
  long long nid = 0;
  for (long long i = 0; i < ((long long((egs[u]).size()))); ++i) {
    if (egs[u][i] == pr) continue;
    if (botegsort[u][0] == boteg[u][nid])
      gentop(
          egs[u][i], u,
          ((long long((botegsort[u]).size())) < 2 ? 1 : (botegsort[u][1] + 1)));
    else
      gentop(egs[u][i], u, botegsort[u][0]);
    ++nid;
  }
  if ((long long((botegsort[u]).size())) >= 2) {
    sm += botegsort[u][1];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  sm = 2 * n - 1;
  egs.resize(n);
  long long ta, tb;
  for (long long z = 0; z < (n - 1); ++z) {
    cin >> ta >> tb;
    --ta;
    --tb;
    egs[ta].push_back(tb);
    egs[tb].push_back(ta);
  }
  boteg.resize(n);
  botegsort.resize(n);
  genbot(0, 0);
  gentop(0, 0, 0);
  cout << sm << endl;
  return 0;
}
