#include <bits/stdc++.h>
using namespace std;
struct Graph {
  int id, next, dis, co;
  bool vis;
} g[3010 * 2];
int st[3010], n, CC = 3010, sum[3010], dis[3010][3010];
void Add(int tot, int x, int y, int dis) {
  g[tot].id = y, g[tot].dis = dis, g[tot].co = dis, g[tot].next = st[x],
  st[x] = tot;
}
void init() {
  scanf("%d", &n);
  memset(st, -1, sizeof(st));
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Add(i * 2, x, y, 0);
    Add(i * 2 + 1, y, x, 1);
  }
}
void Visit1(int x, int f, int s, int d) {
  dis[s][x] = d;
  for (int i = st[x]; i != -1; i = g[i].next)
    if (g[i].id != g[f ^ 1].id)
      Visit1(g[i].id, i, s, d + g[i].dis), g[f].co += (!g[f].vis) ? g[i].co : 0;
  g[f].vis = true;
}
void Visit2(int x, int f, int s, int c, int co, int t) {
  if (f != 0) CC = min(CC, sum[x] - g[f ^ 1].co + co + t);
  if (f == 0)
    t = sum[x];
  else
    t += sum[x] - g[f ^ 1].co;
  for (int i = st[x]; i != -1; i = g[i].next) {
    if (g[i].id == g[f ^ 1].id) continue;
    if (f == 0) c = i;
    Visit2(g[i].id, i, s, c, min(co + g[i ^ 1].dis, dis[s][g[i].id]),
           t - g[i].co);
  }
}
void solve() {
  if (n == 1) puts("0"), exit(0);
  for (int i = 1; i <= n; i++) Visit1(i, 0, i, 0);
  for (int i = 1; i <= n; i++)
    for (int j = st[i]; j != -1; j = g[j].next) sum[i] += g[j].co;
  for (int i = 1; i <= n; i++) Visit2(i, 0, i, 0, 0, 0);
  cout << CC << endl;
}
int main() {
  init();
  solve();
  return 0;
}
