#include <bits/stdc++.h>
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
int n, x, y, ds, ans = int(0x3f3f3f3f), dp[3008], qw;
vector<pair<int, int> > g[3008];
void dfs(int u, int fa, int zz, int d) {
  qw = max(qw, 2 * dp[u] - d + zz);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (v == fa) continue;
    if (g[u][i].second)
      dp[v] = dp[u], dfs(v, u, max(zz, d - 2 * dp[u]), d + 1);
    else
      dp[v] = dp[u] + 1, dfs(v, u, max(zz, d - 2 * dp[u]), d + 1), ds++;
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i(1); i <= (n - 1); ++i) {
    scanf("%d", &x), scanf("%d", &y);
    g[x].push_back(pair<int, int>(y, 1));
    g[y].push_back(pair<int, int>(x, 0));
  }
  for (int i(1); i <= (n); ++i) {
    ds = qw = 0;
    memset(dp, 0, sizeof(dp));
    dfs(i, 0, 0, 0);
    ans = min(ans, ds - qw);
  }
  cout << ans << endl;
  return 0;
}
