#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, nt, val;
} e[6010];
int st[3010];
int n, ans;
int up[3010], down[3010];
void addedge(int k, int u, int v, int val) {
  e[k].v = v;
  e[k].val = val;
  e[k].nt = st[u];
  st[u] = k;
}
void dfs(int k, int f, int d) {
  int x = st[k], mn1 = 0, mn2 = 0;
  while (x) {
    if (e[x].v != f) {
      dfs(e[x].v, k, e[x].val);
      down[k] += down[e[x].v];
      if (mn1 > up[e[x].v] - down[e[x].v]) {
        mn2 = mn1;
        mn1 = up[e[x].v] - down[e[x].v];
      } else if (mn2 > up[e[x].v] - down[e[x].v])
        mn2 = up[e[x].v] - down[e[x].v];
    }
    x = e[x].nt;
  }
  if (f) {
    up[k] = down[k] + mn1;
    if (d == 1)
      up[k]++;
    else
      down[k]++;
  } else if (ans > down[k] + mn1 + mn2)
    ans = down[k] + mn1 + mn2;
}
int main() {
  memset(st, 0, sizeof(st));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(i * 2 - 1, u, v, 1);
    addedge(i * 2, v, u, -1);
  }
  ans = n * 10;
  for (int i = 1; i <= n; i++) {
    memset(up, 0, sizeof(up));
    memset(down, 0, sizeof(down));
    dfs(i, 0, 0);
  }
  printf("%d\n", ans);
  return 0;
}
