#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1E-7;
const int inf = int(1e9) + 7;
const int MAXN = 3000 + 5;
int w[MAXN][MAXN], ori[MAXN][MAXN], father[MAXN];
vector<int> es[MAXN];
int dp[MAXN][2];
int n;
int hzz(int a, int b) {
  if (a == 1 && b == 1) return 1;
  if (a == -1 && b == 0) return 1;
  return 0;
}
int dfs(int x) {
  int base = 0;
  for (int(i) = 0; (i) < (es[x].size()); ++(i))
    if (w[x][es[x][i]]) {
      int y = es[x][i];
      if (father[y] == -1) {
        father[y] = x;
        dfs(y);
        base += hzz(w[x][y], 0) + dp[y][0];
      }
    }
  dp[x][0] = base;
  int tmp = MAXN;
  for (int(i) = 0; (i) < (es[x].size()); ++(i))
    if (w[x][es[x][i]]) {
      int y = es[x][i];
      if (father[y] == x)
        tmp = min(tmp, base - hzz(w[x][y], 0) - dp[y][0] + hzz(w[x][y], 1) +
                           min(dp[y][0], dp[y][1]));
    }
  dp[x][1] = tmp;
  return min(dp[x][0], dp[x][1]);
}
int main() {
  cin >> n;
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  int a, b;
  for (int(rp) = 0; (rp) < (n - 1); ++(rp)) {
    cin >> a >> b;
    w[a][b] = 1;
    w[b][a] = -1;
    ori[a][b] = 1;
    ori[b][a] = -1;
    es[a].push_back(b);
    es[b].push_back(a);
  }
  int ans = MAXN;
  for (int i = 1; i <= n; i++) {
    for (int(j) = 0; (j) < (es[i].size()); ++(j))
      if (w[i][es[i][j]] == 1) {
        w[i][es[i][j]] = 0;
        w[es[i][j]][i] = 0;
        memset(father, -1, sizeof(father));
        father[i] = 0;
        father[es[i][j]] = 0;
        int f1 = dfs(i), f2 = dfs(es[i][j]);
        ans = min(ans, f1 + f2);
        w[i][es[i][j]] = 1;
        w[es[i][j]][i] = -1;
      }
  }
  cout << ans << endl;
  return 0;
}
