#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 5100;
vector<pair<int, int> > conn[maxn];
pair<int, int> p[maxn];
int dp[maxn], dp1[maxn];
int ans = 10100;
void dfs(int cur, int par, int tp) {
  for (int i = 0; i < conn[cur].size(); i++) {
    int to = conn[cur][i].first;
    int vv = conn[cur][i].second;
    if (to != par) {
      dfs(to, cur, vv);
      dp[cur] += dp[to];
    }
  }
  dp[cur] += tp;
}
int go(int cur, int par, int up) {
  dp1[cur] = dp[cur] + up;
  int ms = 10100;
  for (int i = 0; i < conn[cur].size(); i++) {
    int to = conn[cur][i].first;
    int vv = conn[cur][i].second;
    if (to != par) {
      int nn = up + dp[cur] - dp[to];
      if (!vv) {
        nn++;
      } else {
        nn--;
      }
      ms = min(ms, go(to, cur, nn));
    }
  }
  dp1[cur] = min(dp1[cur], ms);
  return dp1[cur];
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    conn[u].push_back(make_pair(v, 0));
    conn[v].push_back(make_pair(u, 1));
    p[i] = make_pair(u, v);
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      dp[j] = 0;
      dp1[j] = 0;
    }
    int u = p[i].first;
    int v = p[i].second;
    dfs(v, u, 0);
    dfs(u, v, 0);
    ans = min(ans, go(v, u, 0) + go(u, v, 0));
  }
  if (ans == 10100) {
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
