#include <bits/stdc++.h>
using namespace std;
vector<int> e[3003], c[3003], id[3003];
int n;
int d[3003][4];
void dfs(int cur, int fa, int va) {
  vector<int> son, w;
  for (int i = 0; i < e[cur].size(); ++i) {
    int u = e[cur][i];
    if (u == fa) continue;
    dfs(u, cur, c[cur][i]);
    son.push_back(u);
    w.push_back(c[cur][i]);
  }
  d[cur][0] = d[cur][1] = va;
  int mx = 10000;
  int sum = 0;
  for (int i = 0; i < son.size(); ++i) {
    sum += d[son[i]][0];
    d[cur][0] += d[son[i]][0];
  }
  for (int i = 0; i < son.size(); ++i) {
    int tmp = ((d[son[i]][2] + w[i]) < (d[son[i]][1]) ? (d[son[i]][2] + w[i])
                                                      : (d[son[i]][1]));
    for (int j = 0; j < son.size(); ++j) {
      if (i != j) tmp += d[son[j]][0];
    }
    if (tmp < mx) mx = tmp;
  }
  d[cur][1] += mx;
  d[cur][2] = 0;
  for (int i = 0; i < son.size(); ++i) d[cur][2] += d[son[i]][0];
  for (int i = 0; i < son.size(); ++i) {
    int tmp = d[son[i]][2] + (1 - w[i]);
    for (int j = 0; j < son.size(); ++j) {
      if (i != j) tmp += d[son[j]][0];
    }
    d[cur][2] = ((tmp) < (d[cur][2]) ? (tmp) : (d[cur][2]));
  }
  d[cur][3] = 1000000000;
  for (int i = 0; i < son.size(); ++i) {
    int tmp = d[son[i]][3] + (1 - w[i]);
    for (int j = 0; j < son.size(); ++j) {
      if (i == j) continue;
      tmp += d[son[j]][0];
    }
    d[cur][3] = ((d[cur][3]) < (tmp) ? (d[cur][3]) : (tmp));
  }
  for (int i = 0; i < son.size(); ++i) {
    int tmp =
        ((d[son[i]][2]) < (d[son[i]][1]) ? (d[son[i]][2]) : (d[son[i]][1]));
    for (int j = 0; j < son.size(); ++j) {
      if (i == j) continue;
      tmp += d[son[j]][0];
    }
    d[cur][3] = ((d[cur][3]) < (tmp) ? (d[cur][3]) : (tmp));
  }
  for (int i = 0; i < son.size(); ++i) {
    for (int j = 0; j < son.size(); ++j) {
      if (i == j) continue;
      int tmp = sum - d[son[i]][0] - d[son[j]][0];
      int res;
      res = d[son[i]][1] + d[son[j]][2] + (1 - w[j]);
      d[cur][3] = ((d[cur][3]) < (tmp + res) ? (d[cur][3]) : (tmp + res));
      res = d[son[i]][2] + d[son[j]][2] +
            ((1 - w[i]) < (1 - w[j]) ? (1 - w[i]) : (1 - w[j]));
      d[cur][3] = ((d[cur][3]) < (tmp + res) ? (d[cur][3]) : (tmp + res));
    }
  }
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
    c[a].push_back(0);
    c[b].push_back(1);
    id[a].push_back(i);
    id[b].push_back(i);
  }
}
void solve() {
  dfs(1, -1, 0);
  if (n <= 2)
    puts("0");
  else
    printf("%d\n", ((d[1][3]) < (d[1][2]) ? (d[1][3]) : (d[1][2])));
}
void prin() {}
int main() {
  init();
  solve();
  prin();
}
