#include <bits/stdc++.h>
using namespace std;
int rev_cnt, max_save;
vector<int> ls1[3005], ls2[3005];
void dfs(int u, int p, int dir, int saved) {
  saved = max(saved + dir, 0);
  max_save = max(max_save, saved);
  for (int i = 0; i < ls1[u].size(); i++) {
    int v = ls1[u][i];
    if (v == p) continue;
    dfs(v, u, -1, saved);
  }
  for (int i = 0; i < ls2[u].size(); i++) {
    int v = ls2[u][i];
    if (v == p) continue;
    rev_cnt++;
    dfs(v, u, 1, saved);
  }
}
int main() {
  int n, u, v, ans;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    ls1[u].push_back(v);
    ls2[v].push_back(u);
  }
  ans = n;
  for (int i = 1; i <= n; i++) {
    rev_cnt = max_save = 0;
    dfs(i, 0, 0, 0);
    ans = min(ans, rev_cnt - max_save);
  }
  cout << ans << endl;
  return 0;
}
