#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T>
ostream& operator<<(ostream& _s, vector<T> _t) {
  for (int i = 0; i < (int)(_t.size()); i++) _s << (i ? " " : "") << _t[i];
  return _s;
}
template <typename T>
istream& operator>>(istream& _s, vector<T>& _t) {
  for (int i = 0; i < (int)(_t.size()); i++) _s >> _t[i];
  return _s;
}
template <typename T, typename U>
ostream& operator<<(ostream& _s, pair<T, U> _t) {
  _s << "(" << _t.first << "," << _t.second << ")";
  return _s;
}
template <typename T, typename U>
istream& operator>>(istream& _s, pair<T, U>& _t) {
  _s >> _t.first >> _t.second;
  return _s;
}
using G = vector<vector<ll>>;
map<pair<int, int>, ll> ds;
ll ans;
ll dfs1(G& g, int a, int fr) {
  ll res = 0;
  for (int b : g[a]) {
    if (b == fr) continue;
    ll x = dfs1(g, b, a);
    ds[{a, b}] = x;
    res = max(res, x);
  }
  return res + 1;
}
void dfs2(G& g, int a, int fr, ll d_fr) {
  vector<pair<ll, int>> cd;
  cd.push_back({d_fr, fr});
  for (int b : g[a]) {
    if (b == fr) continue;
    cd.push_back({ds[{a, b}], b});
  }
  sort(cd.begin(), cd.end());
  reverse(cd.begin(), cd.end());
  ll cur = (cd.size() > 1) ? (cd[1].first + 1) : 1;
  cur = min(cur, cd[0].first - 1);
  ans += cur + 1;
  for (int b : g[a]) {
    if (b == fr) continue;
    ll x = cd[0].first;
    if (cd[0].second == b) {
      x = cd[1].first;
    }
    dfs2(g, b, a, x + 1);
  }
}
void solve() {
  ds.clear();
  int n;
  cin >> n;
  G g(n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(g, 0, -1);
  ans = 0;
  dfs2(g, 0, -1, 0);
  cout << (ans + 1) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t = 1;
  for (int i = 0; i < (int)(t); i++) {
    solve();
  }
}
