#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3005], dir[3005];
int n;
int tot[3005][3005];
void dfs(int root, int u, int p) {
  tot[root][u] = 0;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    int d = dir[u][i];
    if (p == v) continue;
    tot[root][u] += (d == 0);
    dfs(root, v, u), tot[root][u] += tot[root][v];
  }
}
int dp[3005], ans;
void go(int u, int p, int cnt, int root) {
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    int d = dir[u][i];
    if (p == v) continue;
    int ncnt = cnt;
    if (d == 1) {
      dp[v] = min(cnt, dp[u] + 1);
    } else {
      dp[v] = min(cnt + 1, dp[u]);
      ncnt++;
    }
    ans = min(ans, tot[root][root] - ncnt + dp[v]);
    go(v, u, ncnt, root);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v), u--, v--;
    adj[u].push_back(v);
    dir[u].push_back(1);
    adj[v].push_back(u);
    dir[v].push_back(0);
  }
  for (int i = 0; i < n; ++i) dfs(i, i, -1);
  int ANS = 1 << 30;
  for (int r = 0; r < n; ++r) {
    ans = tot[r][r];
    dp[r] = 0;
    go(r, -1, 0, r);
    ANS = min(ANS, ans);
  }
  printf("%d\n", ANS);
}
