#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
}
const int N = 1e5 + 50;
int n, mx[N], sc[N];
long long ans;
vector<int> g[N];
void chk(int v, int w) {
  if (w > mx[v]) {
    sc[v] = mx[v];
    mx[v] = w;
  } else if (w > sc[v]) {
    sc[v] = w;
  }
}
void dp(int v, int p) {
  mx[v] = 1, sc[v] = 0;
  for (int d : g[v])
    if (d != p) {
      dp(d, v);
      chk(v, mx[d] + 1);
    }
}
void calc(int v, int p, int u) {
  chk(v, u);
  ans += min(mx[v], sc[v] + 2) - 1;
  ;
  for (int d : g[v])
    if (d != p) {
      if (mx[v] == mx[d] + 1) {
        calc(d, v, sc[v] + 1);
      } else {
        calc(d, v, mx[v] + 1);
      }
    }
}
int main(int argc, char *argv[]) {
  read(n);
  for (int i = 1; i <= (n - 1); ++i) {
    int u, v;
    read(u), read(v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dp(1, 0);
  calc(1, 0, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
