#include <bits/stdc++.h>
using namespace std;
struct node {
  int u, v;
  int next;
  int len;
} edge[3050 * 2];
int n;
int cnt;
int head[3050];
int ans1, ans2;
int dp[3050 * 2][2];
int ans;
int res;
void addedge(int u, int v, int w) {
  edge[cnt].u = u;
  edge[cnt].v = v;
  edge[cnt].next = head[u];
  edge[cnt].len = w;
  head[u] = cnt++;
}
void dfs1(int root, int fa, int adj) {
  int i, j, k;
  int y;
  dp[root][0] = 0;
  for (i = head[root]; i != -1; i = edge[i].next) {
    y = edge[i].v;
    if (y == fa || y == adj) continue;
    dfs1(y, root, adj);
    dp[root][0] += dp[y][0] + edge[i].len;
  }
}
void dfs2(int root, int fa, int id, int adj) {
  int i, j, k;
  int y;
  if (fa != -1) {
    if (edge[id].len) {
      dp[root][1] = dp[fa][1] - 1;
    } else {
      dp[root][1] = dp[fa][1] + 1;
    }
  }
  ans = min(ans, dp[root][1]);
  for (i = head[root]; i != -1; i = edge[i].next) {
    y = edge[i].v;
    if (y == fa || y == adj) continue;
    dfs2(y, root, i, adj);
  }
}
int main() {
  int i, j;
  cnt = 0;
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    addedge(a, b, 0);
    addedge(b, a, 1);
  }
  if (n == 1) {
    puts("0");
    return 0;
  }
  res = 1 << 25;
  for (i = 0; i < cnt; i = i + 2) {
    int u, v;
    u = edge[i].u;
    v = edge[i].v;
    dfs1(u, -1, v);
    dp[u][1] = dp[u][0];
    ans = 1 << 25;
    dfs2(u, -1, -1, v);
    ans1 = ans;
    dfs1(v, -1, u);
    dp[v][1] = dp[v][0];
    ans = 1 << 25;
    dfs2(v, -1, -1, u);
    ans2 = ans;
    res = min(ans1 + ans2, res);
  }
  printf("%d\n", res);
  return 0;
}
