#include <bits/stdc++.h>
const int maxn = 3005, maxm = maxn << 1;
int n, e, ans, minn;
int start[maxn], to[maxm], then[maxm], worth[maxm], f[maxn], tot[maxn],
    xx[maxm], yy[maxm];
inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }
inline void add(int x, int y, int z) {
  then[++e] = start[x], start[x] = e, to[e] = y, worth[e] = z;
}
void dfs(int x, int last) {
  minn = min(minn, tot[x]);
  for (int i = start[x]; i; i = then[i]) {
    int y = to[i];
    if (y == last) continue;
    tot[y] = tot[x] + (worth[i] == 0 ? -1 : 1);
    dfs(y, x);
    f[x] += f[y] + (worth[i] ^ 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y, 1), add(y, x, 0);
  }
  ans = n - 1;
  for (int i = 1; i <= n; i++)
    for (int j = start[i]; j; j = then[j])
      if (worth[j] == 1) {
        int k = to[j], sum = 0;
        for (int p = 1; p <= n; p++) f[p] = tot[p] = 0;
        dfs(i, 0), ans = min(ans, f[i]);
        for (int p = 1; p <= n; p++) f[p] = tot[p] = 0;
        minn = 1000000000, dfs(i, k);
        sum += f[i] + minn;
        for (int p = 1; p <= n; p++) f[p] = tot[p] = 0;
        minn = 1000000000, dfs(k, i);
        sum += f[k] + minn;
        ans = min(ans, sum);
      }
  printf("%d\n", ans);
  return 0;
}
