#include <bits/stdc++.h>
using namespace std;
const int mx = 3e3 + 4;
vector<pair<int, int> > v[mx];
int dp[mx], h[mx], ha[mx];
int ans[mx], dpop[mx][mx];
void dfs(int x, int p) {
  h[x] += h[p] + 1;
  for (int i = 0; i < v[x].size(); i++) {
    pair<int, int> l = v[x][i];
    if (l.first != p) {
      ha[l.first] += !(l.second) + ha[x];
      dfs(l.first, x);
      dp[x] += dp[l.first];
      dp[x] += !(l.second);
    }
  }
}
void dfs1(int y, int x, int p) {
  pair<int, int> l;
  for (int i = 0; i < v[x].size(); i++) {
    l = v[x][i];
    if (l.first != p) {
      if (l.second == 1)
        dpop[y][l.first] = max(dpop[y][x] - 1, 0);
      else
        dpop[y][l.first] = dpop[y][x] + 1;
      dfs1(y, l.first, x);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(pair<int, int>(y, 1));
    v[y].push_back(pair<int, int>(x, 0));
  }
  h[0] = -1;
  dfs(1, 0);
  ans[1] = dp[1];
  for (int i = 1; i <= n; i++) ans[i] = ans[1] + (h[i] - 2 * ha[i]);
  int min1 = 1e9;
  dfs1(1, 0, 0);
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; i++) dfs1(i, i, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) min1 = min(min1, ans[i] - dpop[i][j]);
  }
  cout << min1;
}
