#include <bits/stdc++.h>
using namespace std;
vector<int> g[200005];
int p[200005];
int n;
int subtreeAns[200005];
int level[4][200005];
int ans[200005];
int ansLevel[200005];
void removeParents(int v, int vp) {
  p[v] = vp;
  for (auto& vn : g[v]) {
    if (vn == vp) {
      vn = g[v].back();
      g[v].pop_back();
      break;
    }
  }
  for (const auto vn : g[v]) {
    removeParents(vn, v);
  }
}
void getSubtreeAns(int v) {
  subtreeAns[v] = 0;
  for (int i = 0; i <= 3; ++i) {
    level[i][v] = 0;
  }
  if (g[v].size() == 0) {
    return;
  }
  for (const auto vn : g[v]) {
    getSubtreeAns(vn);
    subtreeAns[v] += g[vn].size();
    for (int i = 1; i <= 3; ++i) {
      level[i][v] += level[i - 1][vn];
    }
  }
  subtreeAns[v] += level[3][v];
  level[0][v] = (int)g[v].size() + level[2][v];
}
void getAns(int v) {
  if (v == 0) {
    ans[v] = subtreeAns[v];
    ansLevel[v] = level[0][v];
  } else {
    ans[v] = subtreeAns[v];
    ans[v] += ((int)g[p[v]].size() + level[2][p[v]]) - (1 + level[1][v]);
    if (p[p[v]] != -1) {
      int ded = p[p[v]];
      int praded = p[ded];
      ++ans[v];
      ans[v] += level[1][ded] - level[0][p[v]];
      if (praded != -1) {
        ans[v] += ansLevel[praded] - 1 - level[1][ded];
      }
    }
    ansLevel[v] = (int)g[v].size() + 1;
    ansLevel[v] += level[2][v] + (level[1][p[v]] - level[0][v]);
    if (p[p[v]] != -1) {
      int ded = p[p[v]];
      ansLevel[v] += ansLevel[ded] - 1 - level[1][p[v]];
    }
  }
  for (const auto vn : g[v]) {
    getAns(vn);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  removeParents(0, -1);
  getSubtreeAns(0);
  getAns(0);
  int ansMin = 2 * n;
  for (int i = 0; i < n; ++i) {
    ansMin = min(ansMin, ans[i]);
  }
  printf("%d\n", ansMin);
  return 0;
}
