#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > g[3030];
vector<pair<int, int> > e;
int dp[3030];
void dfs(int v, int p) {
  dp[v] = 0;
  for (auto i : g[v]) {
    int to = i.first, cost = i.second;
    if (to == p) continue;
    dfs(to, v);
    dp[v] += (dp[to] + cost);
  }
}
int calc(int v, int p, int up = 0) {
  int ans = 130303;
  ans = min(ans, dp[v] + up);
  for (auto i : g[v]) {
    int to = i.first, cost = i.second;
    if (to == p) continue;
    ans = min(ans, calc(to, v, up + (dp[v] - (cost + dp[to])) + (cost ^ 1)));
  }
  return ans;
}
int ans = 130303;
int main() {
  cin >> n;
  if (n == 1) {
    cout << 0;
    exit(0);
  }
  for (int i = 1, a, b; i < n; i++) {
    cin >> a >> b;
    g[a].push_back(make_pair(b, 0));
    g[b].push_back(make_pair(a, 1));
    e.push_back(make_pair(a, b));
  }
  for (auto it : e) {
    dfs(it.first, it.second);
    dfs(it.second, it.first);
    ans = min(ans, calc(it.first, it.second) + calc(it.second, it.first));
  }
  cout << ans;
}
