#include <bits/stdc++.h>
using namespace std;
const int N = 3005, INF = 1e7;
int n, ans, f[N], g[N], A[N], B[N], par[N];
vector<pair<int, int> > ke[N];
void dfs1(int u) {
  f[u] = 0;
  for (auto v : ke[u])
    if (v.first != par[u]) {
      par[v.first] = u;
      dfs1(v.first);
      f[u] += f[v.first] + v.second;
    }
}
void dfs2(int u, int mi) {
  mi = min(mi, B[u] - A[u]);
  ans = min(ans, f[u] + g[u] + A[u] + mi);
  for (auto v : ke[u])
    if (v.first != par[u]) {
      g[v.first] = g[u] + f[u] - f[v.first] - v.second;
      A[v.first] = A[u] + 1 - v.second;
      B[v.first] = B[u] + v.second;
      dfs2(v.first, mi);
    }
}
int main() {
  ios::sync_with_stdio();
  cin.tie(0);
  cin >> n;
  for (int i = 1, loop = n - 1; i <= loop; ++i) {
    int u, v;
    cin >> u >> v;
    ke[u].push_back(make_pair(v, 0));
    ke[v].push_back(make_pair(u, 1));
  }
  ans = INF;
  for (int i = 1, loop = n; i <= loop; ++i) {
    par[i] = 0;
    dfs1(i);
    ans = min(ans, f[i]);
    for (auto j : ke[i]) {
      g[j.first] = f[i] - f[j.first] - j.second;
      A[j.first] = 1 - j.second;
      B[j.first] = j.second;
      dfs2(j.first, INF);
    }
  }
  cout << ans;
}
