#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
bool mat[maxn][maxn];
int cost[maxn], dp[maxn], cur, n;
vector<int> adj[maxn];
void cfs(int u, int par) {
  cost[u] = 0;
  for (int v : adj[u]) {
    if (v != par) {
      cfs(v, u);
      cost[u] += cost[v] + mat[v][u];
    }
  }
}
void pfs(int u, int par) {
  dp[u] = cost[u];
  if (par != -1) {
    dp[u] = dp[par] - mat[u][par] + mat[par][u];
    dp[u] = min(dp[u], cost[cur]);
  }
  for (int v : adj[u]) {
    if (v != par) {
      pfs(v, u);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    mat[u][v] = true;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    cur = i;
    cfs(i, -1);
    pfs(i, -1);
    ans = min(ans, *min_element(dp, dp + n));
  }
  cout << ans << '\n';
  return 0;
}
