#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[200005];
int dep[200005];
void dfs(int first, int f) {
  for (auto &it : v[first]) {
    if (it.second != f) {
      dfs(it.second, first);
      it.first = dep[it.second] + 1;
    }
  }
  sort(v[first].begin(), v[first].end());
  reverse(v[first].begin(), v[first].end());
  if (f != 0 && v[first].size() == 1)
    ;
  else
    dep[first] = v[first][0].first;
}
void dfs2(int first, int f, int sum) {
  for (auto it : v[first]) {
    if (it.second != f) {
      if (it.first == v[first][0].first) {
        if (v[first].size() == 1) {
          dfs2(it.second, first, sum + 1);
        } else {
          dfs2(it.second, first, max(v[first][1].first, sum) + 1);
        }
      } else {
        dfs2(it.second, first, max(v[first][0].first, sum) + 1);
      }
    }
  }
  if (f != 0) {
    v[first].back().first = sum;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    v[first].push_back(make_pair(-1, second));
    v[second].push_back(make_pair(-1, first));
  }
  dfs(1, 0);
  dfs2(1, 0, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
    if (v[i].size() == 1) {
      ans += 2;
      if (v[i][0].first == 1) ans--;
    } else {
      ans += v[i][1].first + 2;
      if (v[i][1].first == v[i][0].first) ans -= 2;
      if (v[i][1].first == v[i][0].first - 1) ans--;
    }
  }
  printf("%lld\n", ans + 1);
}
