#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
vector<pair<int, int> > v[N];
int ps[N], mx[N], cnt, wr;
void dfs(int u, int par) {
  for (auto y : v[u]) {
    if (y.first == par) continue;
    ps[y.first] = ps[u];
    if (y.second == 1)
      ps[y.first]++;
    else {
      wr++;
      ps[y.first]--;
    }
    mx[y.first] = max(mx[u], ps[y.first]);
    cnt = min(cnt, ps[y.first] - mx[y.first]);
    dfs(y.first, u);
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(make_pair(b, 1));
    v[b].push_back(make_pair(a, 2));
  }
  int ans = n - 1;
  for (int i = 0; i < n; i++) {
    fill(mx, mx + N, 0);
    fill(ps, ps + N, 0);
    cnt = 0;
    wr = 0;
    dfs(i, -1);
    ans = min(ans, wr + cnt);
  }
  cout << ans;
  return 0;
}
