#include <bits/stdc++.h>
template <typename T>
inline void read(T &first) {
  char c = first = 0;
  for (c = getchar(); !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar())
    first = (first << 3) + (first << 1) + (c ^ 48);
}
namespace gg {
template <typename T>
inline bool check_max(T a, T &b) {
  return a > b ? b = a, 1 : 0;
}
struct node {
  int s[4];
  void reset() { s[0] = s[1] = s[2] = s[3] = -1; }
};
std::pair<int, int> operator-(node A, std::pair<int, int> B) {
  if (B.first == A.s[0]) {
    if (B.second == A.s[1]) return std::pair<int, int>(A.s[2], A.s[3]);
    if (B.second == A.s[2]) return std::pair<int, int>(A.s[1], A.s[3]);
    return std::pair<int, int>(A.s[1], A.s[2]);
  } else {
    if (B.first == A.s[1]) {
      if (B.second == A.s[2]) return std::pair<int, int>(A.s[0], A.s[3]);
      return std::pair<int, int>(A.s[0], A.s[2]);
    }
    return std::pair<int, int>(A.s[0], A.s[1]);
  }
}
inline void insert(int a, std::pair<int, int> &b) {
  check_max(a, b.second);
  if (b.second > b.first) std::swap(b.first, b.second);
}
inline void insert(int a, node &b) {
  if (check_max(a, b.s[3]))
    for (int i = 3; i && b.s[i] > b.s[i - 1]; i--)
      std::swap(b.s[i], b.s[i - 1]);
}
const int M = 101000, N = M * 2;
int begin[N], next[M], to[M];
int fa[N];
int n, e;
void add(int first, int second, bool k = 1) {
  to[++e] = second;
  next[e] = begin[first];
  begin[first] = e;
  if (k) add(second, first, 0);
}
std::pair<int, int> f[N];
void dfs0(int p, int h = 0) {
  fa[p] = h;
  f[p] = std::pair<int, int>(0, 0);
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != h) {
      dfs0(q, p);
      insert(f[q].first + 1, f[p]);
    }
}
void dfs1(int p, int dis = 0) {
  insert(dis, f[p]);
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != fa[p]) {
      int first = std::max(dis, (f[q].first + 1 == f[p].first ? f[p].second
                                                              : f[p].first)) +
                  1;
      dfs1(q, first);
    }
}
void initialize() {
  read(n);
  for (int i = 1, u, v; i < n; i++) read(u), read(v), add(u, v);
}
void solve() {
  initialize();
  dfs0(1), dfs1(1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += std::min(f[i].first - 1, f[i].second + 1) + 1;
  }
  printf("%lld\n", ans + 1);
}
}  // namespace gg
int main() {
  gg::solve();
  return 0;
}
