#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, a[N], b[N], ans, dp[N];
vector<int> adj[2][N];
bool vis[N];
void dfs(int x) {
  vis[x] = true;
  dp[x] = 0;
  for (int y : adj[0][x]) {
    if (!vis[y]) {
      dfs(y);
      dp[x] += dp[y];
    }
  }
  for (int y : adj[1][x]) {
    if (!vis[y]) {
      dfs(y);
      dp[x] += 1 + dp[y];
    }
  }
}
void dfs2(int x) {
  vis[x] = true;
  int res = dp[x];
  for (int y : adj[0][x]) {
    if (!vis[y]) {
      dp[y] = 1 + dp[x];
      dfs2(y);
      res = min(res, dp[y]);
    }
  }
  for (int y : adj[1][x]) {
    if (!vis[y]) {
      dp[y] = -1 + dp[x];
      dfs2(y);
      res = min(res, dp[y]);
    }
  }
  dp[x] = res;
}
void solve(int e) {
  for (int i = (1); i < (n + 1); i++) {
    adj[0][i].clear();
    adj[1][i].clear();
  }
  for (int i = (0); i < (n - 1); i++) {
    if (i != e) {
      adj[0][a[i]].push_back(b[i]);
      adj[1][b[i]].push_back(a[i]);
    }
  }
  fill(vis + 1, vis + n + 1, false);
  dfs(a[e]);
  fill(vis + 1, vis + n + 1, false);
  dfs(b[e]);
  fill(vis + 1, vis + n + 1, false);
  dfs2(a[e]);
  fill(vis + 1, vis + n + 1, false);
  dfs2(b[e]);
  ans = min(ans, dp[a[e]] + dp[b[e]]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  ans = n - 1;
  for (int i = (0); i < (n - 1); i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = (0); i < (n - 1); i++) {
    solve(i);
  }
  cout << ans << '\n';
}
