#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long long INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MAX = 200200;
struct edge {
  int x, y;
  int depth;
  edge() {
    x = y = -1;
    depth = 0;
  }
};
vector<edge> E;
vector<int> g[MAX];
vector<int> I[MAX];
vector<int> L[MAX];
vector<int> R[MAX];
int D[MAX];
int dfs1(int x, int p) {
  int res = 0;
  for (int i = (0); i < ((int)g[x].size()); i++) {
    int e = g[x][i];
    int to = E[e].y;
    if (to == p) continue;
    E[e].depth = dfs1(to, x);
    res = max(res, E[e].depth);
  }
  return res + 1;
}
void dfs2(int x, int p, int ind) {
  if (ind != -1) {
    int r = I[x][ind];
    int mx = 0;
    if (r) mx = max(mx, L[p][r - 1]);
    if (r < (int)g[p].size() - 1) mx = max(mx, R[p][r + 1]);
    mx++;
    int e = g[x][ind];
    E[e].depth = mx;
  }
  L[x].resize((int)g[x].size());
  R[x].resize((int)g[x].size());
  int mx = 0;
  int mx2 = 0;
  for (int i = (0); i < ((int)g[x].size()); i++) {
    int e = g[x][i];
    int val = E[e].depth;
    L[x][i] = R[x][i] = val;
    if (val > mx) {
      mx2 = mx;
      mx = val;
    } else {
      if (val > mx2) {
        mx2 = val;
      }
    }
  }
  D[x] = min(mx - 1, mx2 + 1);
  for (int i = (1); i < ((int)g[x].size()); i++) {
    L[x][i] = max(L[x][i], L[x][i - 1]);
  }
  for (int i = ((int)g[x].size() - 1) - 1; i >= (0); i--) {
    R[x][i] = max(R[x][i], R[x][i + 1]);
  }
  for (int i = (0); i < ((int)g[x].size()); i++) {
    int e = g[x][i];
    int to = E[e].y;
    if (to == p) continue;
    dfs2(to, x, I[x][i]);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    I[x].push_back((int)g[y].size());
    I[y].push_back((int)g[x].size());
    edge e;
    e.x = x;
    e.y = y;
    g[x].push_back((int)E.size());
    E.push_back(e);
    e.x = y;
    e.y = x;
    g[y].push_back((int)E.size());
    E.push_back(e);
  }
  dfs1(0, -1);
  dfs2(0, -1, -1);
  long long res = 0;
  for (int i = (0); i < (n); i++) {
    res += D[i] + 1;
  }
  res++;
  cout << res << endl;
}
