#include <bits/stdc++.h>
using namespace std;
int n, in[3005];
struct node {
  int to, dir;
};
vector<node> g[3005];
vector<int> ver, belong[3005];
int vis[3005], fa[3005], dp[2][3005], num;
int e1[3005], e2[3005];
void dfs_1(int u, int pre) {
  for (int i = 0; i < g[u].size(); i++) {
    int to = g[u][i].to, dir = g[u][i].dir;
    if (to == pre)
      continue;
    else {
      dfs_1(to, u);
      dp[0][u] += dp[0][to];
      dp[1][u] += dp[1][to];
      dp[dir][u]++;
    }
  }
}
void dfs_2(int u, int pre, int num_0, int num_1) {
  int sum_0 = num_0, sum_1 = num_1;
  for (int i = 0; i < g[u].size(); i++) {
    int to = g[u][i].to, dir = g[u][i].dir;
    if (to == pre) continue;
    sum_0 += dp[0][to];
    sum_1 += dp[1][to];
    if (dir)
      sum_1++;
    else
      sum_0++;
  }
  for (int i = 0; i < g[u].size(); i++) {
    int to = g[u][i].to, dir = g[u][i].dir;
    if (to == pre) continue;
    int Next_0 = sum_0 - dp[0][to];
    int Next_1 = sum_1 - dp[1][to];
    if (dir)
      Next_1--, Next_0++;
    else
      Next_1++, Next_0--;
    dfs_2(to, u, Next_0, Next_1);
  }
  dp[0][u] += num_0;
  dp[1][u] += num_1;
  num = min(num, dp[1][u]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    e1[i] = a, e2[i] = b;
    g[a].push_back((node){b, 0});
    g[b].push_back((node){a, 1});
  }
  int ans = 100005;
  if (n <= 2) ans = 0;
  for (int i = 1; i < n; i++) {
    int res = 0;
    memset(dp, 0, sizeof(dp));
    num = 100005;
    dfs_1(e1[i], e2[i]);
    dfs_2(e1[i], e2[i], 0, 0);
    res += num;
    memset(dp, 0, sizeof(dp));
    num = 100005;
    dfs_1(e2[i], e1[i]);
    dfs_2(e2[i], e1[i], 0, 0);
    res += num;
    ans = min(ans, res);
  }
  printf("%d\n", ans);
  return 0;
}
