#include <bits/stdc++.h>
using namespace std;
const int MAX = 3000 + 9;
const long long MOD = 1e9 + 7;
vector<pair<int, int> > g[MAX];
pair<int, int> E[MAX];
int dp[MAX], num[MAX];
int dfs(int v, int cost, int root = -1) {
  num[v] = cost;
  if (root != -1) {
    if (num[v] == num[root])
      dp[v] = min(num[v], dp[root] + 1);
    else
      dp[v] = min(num[v], dp[root]);
  }
  int sum = 0;
  for (auto x : g[v]) {
    int u = x.first;
    int id = x.second;
    if (u == root) continue;
    sum += dfs(u, cost + ((E[id].first == v) ? 0 : 1), v) +
           ((E[id].first == v) ? 0 : 1);
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    E[i] = make_pair(v, u);
    g[v].push_back(make_pair(u, i));
    g[u].push_back(make_pair(v, i));
  }
  int res = n;
  for (int i = 0; i < n; i++) {
    memset(dp, 0, sizeof dp);
    memset(num, 0, sizeof num);
    int f = dfs(i, 0);
    res = min(res, f);
    for (int t = 0; t < n; t++) {
      if (t == i) continue;
      int cur = f - num[t] + dp[t];
      res = min(res, cur);
    }
  }
  cout << res << "\n";
}
