#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 10;
vector<int> g[N], d[N];
int n, need, tmp, mtmp;
void read_data() {
  scanf("%d", &n);
  int i, x, y;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    d[x].push_back(1);
    g[y].push_back(x);
    d[y].push_back(-1);
  }
}
void DFS_get(int v, int p) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != p) {
      if (d[v][i] == -1) need++;
      DFS_get(g[v][i], v);
    }
}
void DFS_ans(int v, int p, int x) {
  mtmp = min(mtmp, x);
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != p) DFS_ans(g[v][i], v, x + d[v][i]);
}
void work_edge(int v, int u) {
  need = 0;
  DFS_get(u, v);
  mtmp = n;
  DFS_ans(u, v, need);
  tmp += mtmp;
}
int main() {
  read_data();
  int v, u, i, j, answer = n;
  for (i = 1; i <= n; i++)
    for (j = 0; j < g[i].size(); j++)
      if (d[i][j] == 1) {
        v = i;
        u = g[i][j];
        tmp = 0;
        work_edge(v, u);
        work_edge(u, v);
        answer = min(answer, tmp);
      }
  if (n == 1) answer = 0;
  printf("%d\n", answer);
}
