#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3005];
vector<bool> type[3005];
int n;
int tot, best;
int dp[3001];
void dfs(int x, int p) {
  dp[x] = 0;
  int omar = adj[x].size();
  for (int i = 0; i < omar; ++i) {
    if (adj[x][i] == p) continue;
    tot += type[x][i];
    dfs(adj[x][i], x);
    dp[x] = max(dp[x], dp[adj[x][i]] + 2 * type[x][i] - 1);
  }
  best = max(best, dp[x]);
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    type[v].push_back(1);
    type[u].push_back(0);
  }
  int ans = n;
  for (int i = 1; i <= n; ++i) {
    tot = 0, best = 0;
    dfs(i, -1);
    ans = min(ans, tot - best);
  }
  cout << ans << endl;
}
