#include <bits/stdc++.h>
using namespace std;
int ecnt;
struct Edge {
  int to, w;
  Edge *next;
} * mat[3005], edges[3005 * 2];
void link(int x, int to, int w) {
  edges[ecnt].to = to;
  edges[ecnt].w = w;
  edges[ecnt].next = mat[x];
  mat[x] = &edges[ecnt++];
}
int n, dp[3005][2];
void dfs(int x, int father) {
  dp[x][0] = dp[x][1] = 0;
  int k = 0;
  for (Edge *p = mat[x]; p; p = p->next) {
    int to = p->to;
    if (to == father) continue;
    dfs(to, x);
    dp[x][1] += dp[to][1] + (p->w ^ 1);
    k = min(dp[to][0] + p->w - dp[to][1] - (p->w ^ 1), k);
  }
  dp[x][0] = dp[x][1] + k;
}
int solve(int x) {
  int tol = 0, g = 0, h = 0;
  for (Edge *p = mat[x]; p; p = p->next) {
    int to = p->to;
    dfs(to, x);
    tol += dp[to][1] + (p->w ^ 1);
    int k = dp[to][0] + (p->w) - dp[to][1] - (p->w ^ 1);
    if (k < g)
      h = g, g = k;
    else if (k < h)
      h = k;
  }
  return tol + g + h;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    link(x, y, 1);
    link(y, x, 0);
  }
  int ans = 0x7fffffff;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, solve(i));
  }
  printf("%d\n", ans);
  return 0;
}
