#include <bits/stdc++.h>
using namespace std;
int P, up[4000], d[3005][3005], down[4000], n, x, y, res[4000],
    ans = 2000000000, S;
vector<int> g[3005];
void DFS(int v, int p) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != p) {
      if (d[v][g[v][i]])
        down[P]++;
      else
        up[P]++;
      DFS(g[v][i], v);
    }
}
void dfs(int v, int p, int dist, int UP) {
  res[P] = min(res[P], up[P] - 2 * UP + dist);
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != p) dfs(g[v][i], v, dist + 1, (!d[v][g[v][i]] ? 1 : 0) + UP);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    d[x][y] = 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  P = 1;
  DFS(1, -1);
  res[1] = 2000000000;
  dfs(1, -1, 0, 0);
  if (!res[1]) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < g[i].size(); j++)
      P = g[i][j], up[P] = 0, down[P] = 0, DFS(P, i);
    for (int j = 0; j < g[i].size(); j++)
      P = g[i][j], res[P] = 2000000000, dfs(P, i, 0, 0);
    S = 0;
    for (int j = 0; j < g[i].size(); j++)
      S += (up[g[i][j]] + (d[i][g[i][j]] ? 0 : 1));
    for (int j = 0; j < g[i].size(); j++)
      for (int k = j + 1; k < g[i].size(); k++)
        ans = min(ans, res[g[i][j]] + res[g[i][k]] + S - up[g[i][j]] -
                           up[g[i][k]] - (d[i][g[i][j]] ? 0 : 1) -
                           (d[i][g[i][k]] ? 0 : 1) + (d[i][g[i][j]] ? 1 : 0) +
                           (d[i][g[i][k]] ? 1 : 0));
  }
  cout << (ans == 2000000000 ? 0 : ans);
}
