#include <bits/stdc++.h>
using namespace std;
const int maxn = 3333;
int cnt[maxn][maxn][2], fuck[maxn], dep[maxn][maxn], dis[maxn][maxn];
struct Edge {
  int t, next, v;
} edge[maxn << 1];
int head[maxn], tot, n;
void new_edge(int a, int b, int t) {
  edge[tot].t = b;
  edge[tot].next = head[a];
  edge[tot].v = t;
  head[a] = tot++;
}
void dfs(int u, int fa, int rt) {
  int i;
  for (i = head[u]; i != -1; i = edge[i].next) {
    int e = edge[i].t;
    if (e == fa) continue;
    dep[rt][e] = dep[rt][u] + 1;
    int add = edge[i].v;
    cnt[rt][e][1] = min(cnt[rt][u][0], cnt[rt][u][1]) + !add;
    cnt[rt][e][0] = cnt[rt][u][0] + add;
    dis[rt][e] = dis[rt][u] + add;
    fuck[rt] += add;
    dfs(e, u, rt);
  }
}
int main() {
  tot = 0;
  int i, j, k;
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    new_edge(a, b, 0);
    new_edge(b, a, 1);
  }
  for (i = 1; i <= n; i++) dfs(i, 0, i);
  int ans = 111111111;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      ans = min(ans, fuck[i] - dis[i][j] + min(cnt[i][j][0], cnt[i][j][1]));
      ans = min(ans, fuck[i]);
    }
  printf("%d\n", ans);
  return 0;
}
