#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 5;
int mini, dp[maxn][2];
vector<pair<int, int> > edge[maxn];
void dfs1(int u, int f, int c) {
  dp[u][0] = 0;
  for (vector<pair<int, int> >::iterator it = edge[u].begin();
       it != edge[u].end(); it++) {
    int to = it->first;
    int w = it->second;
    if (to == f || to == c) continue;
    dfs1(to, u, c);
    dp[u][0] += (dp[to][0] + w);
  }
}
void dfs2(int u, int f, int c) {
  if (mini > dp[u][1]) mini = dp[u][1];
  for (vector<pair<int, int> >::iterator it = edge[u].begin();
       it != edge[u].end(); it++) {
    int to = it->first;
    int w = it->second;
    if (to == f || to == c) continue;
    if (w)
      dp[to][1] = dp[u][1] - 1;
    else
      dp[to][1] = dp[u][1] + 1;
    dfs2(to, u, c);
  }
}
int main() {
  int n, s, t;
  vector<pair<int, int> > gr;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &s, &t);
    edge[s].push_back(make_pair(t, 0));
    edge[t].push_back(make_pair(s, 1));
    gr.push_back(make_pair(s, t));
  }
  int ret = maxn;
  for (vector<pair<int, int> >::iterator it = gr.begin(); it != gr.end();
       it++) {
    s = it->first;
    t = it->second;
    dfs1(s, 0, t);
    dp[s][1] = dp[s][0];
    mini = maxn;
    dfs2(s, 0, t);
    int ans1 = mini;
    dfs1(t, 0, s);
    mini = maxn;
    dp[t][1] = dp[t][0];
    dfs2(t, 0, s);
    int ans2 = mini;
    if (ret > ans1 + ans2) ret = ans1 + ans2;
  }
  if (n == 1) ret = 0;
  printf("%d\n", ret);
  return 0;
}
