#include <bits/stdc++.h>
using namespace std;
const int maxn = 3010;
vector<pair<int, int> > edge[maxn];
int dp[maxn][2];
int dd[maxn];
int sum;
void dfs(int u, int f, int tag) {
  if (f == -1) {
    dp[u][0] = dp[u][1] = 0;
    dd[u] = 0;
  } else {
    dp[u][1] = dp[f][1] + tag;
    dp[u][0] = min(dp[f][0], dp[f][1]) + !tag;
    dd[u] = dd[f] + tag;
  }
  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) continue;
    sum += w;
    dfs(to, u, w);
  }
}
int main() {
  int n, a, b;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    edge[a].push_back(make_pair(b, 0));
    edge[b].push_back(make_pair(a, 1));
  }
  int ans = maxn;
  for (int i = 1; i <= n; i++) {
    sum = 0;
    dfs(i, -1, 0);
    for (int j = 1; j <= n; j++) {
      ans = min(ans, sum + min(dp[j][0], dp[j][1]) - dd[j]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
