#include <bits/stdc++.h>
using namespace std;
const int NMAX = 200005;
vector<int> G[NMAX];
int h[NMAX];
int64_t ans = 1;
void dfs1(int node, int prev) {
  for (int to : G[node]) {
    if (to != prev) {
      dfs1(to, node);
      h[node] = max(h[node], h[to]);
    }
  }
  ++h[node];
}
void dfs2(int node, int prev, int hup) {
  int hmax1 = hup, hmax2 = 0;
  for (int to : G[node]) {
    if (to != prev) {
      if (h[to] > hmax1) {
        hmax2 = hmax1;
        hmax1 = h[to];
      } else if (h[to] > hmax2) {
        hmax2 = h[to];
      }
    }
  }
  hmax1++;
  hmax2++;
  if (hmax1 == hmax2) {
    ans += hmax2 - 1;
  } else {
    ans += hmax2;
    if (hmax1 > hmax2 + 1) {
      ans++;
    }
  }
  for (int to : G[node]) {
    if (to != prev) {
      if (h[to] == hmax1 - 1) {
        dfs2(to, node, hmax2);
      } else {
        dfs2(to, node, hmax1);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs1(0, -1);
  dfs2(0, -1, 0);
  cout << ans << '\n';
}
