#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
int as;
struct tree {
  int mx[200005], smx[200005];
  int hd[200005], vr[400005], nt[400005], tt;
  void push(int x, int y) {
    vr[++tt] = y;
    nt[tt] = hd[x];
    hd[x] = tt;
  }
  void dfs0(int nw, int en) {
    mx[nw] = 0;
    smx[nw] = -INF;
    for (int i = hd[nw]; i; i = nt[i]) {
      if (vr[i] == en) continue;
      dfs0(vr[i], nw);
      if (mx[nw] < mx[vr[i]] + 1) {
        smx[nw] = mx[nw];
        mx[nw] = mx[vr[i]] + 1;
      } else
        smx[nw] = max(smx[nw], mx[vr[i]] + 1);
    }
  }
  void dfs1(int nw, int en) {
    if (nw != 1) {
      if (mx[nw] + 1 == mx[en]) {
        if (mx[nw] < smx[en] + 1) {
          smx[nw] = mx[nw];
          mx[nw] = smx[en] + 1;
        } else
          smx[nw] = max(smx[nw], smx[en] + 1);
      } else {
        if (mx[nw] < mx[en] + 1) {
          smx[nw] = mx[nw];
          mx[nw] = mx[en] + 1;
        } else
          smx[nw] = max(smx[nw], mx[en] + 1);
      }
    }
    for (int i = hd[nw]; i; i = nt[i]) {
      if (vr[i] == en) continue;
      dfs1(vr[i], nw);
    }
  }
  void dfs2(int nw, int en) {
    as = as + min(smx[nw] + 1, mx[nw] - 1) + 1;
    for (int i = hd[nw]; i; i = nt[i]) {
      if (vr[i] == en) continue;
      dfs2(vr[i], nw);
    }
  }
} T;
int n, x, y;
int main() {
  scanf("%d", &n);
  for (int i = (1); i < (n); ++i) {
    scanf("%d%d", &x, &y);
    T.push(x, y);
    T.push(y, x);
  }
  T.dfs0(1, 0);
  T.dfs1(1, 0);
  T.dfs2(1, 0);
  cout << as + 1 << endl;
  return 0;
}
