#include <bits/stdc++.h>
using std::cin;
using std::cout;
struct pii {
  int v, dr;
  pii() {}
  pii(int _v, int d) : v(_v), dr(d) {}
};
int n, dad[3000 + 1][3], topo[3000 + 1], ans, dp1[3000 + 1], dp2[3000 + 1],
    dp3[3000 + 1], dp4[3000 + 1];
std::vector<pii> adjl[3000 + 1];
int min(int a, int b) { return (b < a) ? b : a; }
void in() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    adjl[u].push_back(pii(v, 1));
    adjl[v].push_back(pii(u, 0));
  }
}
void bfsanddp() {
  std::queue<int> q;
  q.push(1);
  dad[1][0] = -1;
  topo[1] = 1;
  int cnt = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adjl[u].size(); ++i) {
      int v = adjl[u][i].v;
      if (dad[v][0] == 0) {
        dad[v][0] = u;
        dad[v][1] = !adjl[u][i].dr;
        topo[++cnt] = v;
        q.push(v);
      }
    }
  }
  for (int i = n; i > 1; --i) {
    int u = topo[i];
    dp1[dad[u][0]] += dp1[u] + dad[u][1];
  }
  for (int i = 1; i <= n; ++i) {
    int u = topo[i];
    for (int i = 0; i < adjl[u].size(); ++i) {
      int v = adjl[u][i].v;
      if (v == dad[u][0]) continue;
      dp2[v] = dp2[u] + dp1[u] - dp1[v] + (adjl[u][i].dr << 1) - 1;
    }
  }
}
int csub(int s, int s0) {
  std::queue<int> q;
  q.push(s);
  dad[s][2] = -1;
  topo[1] = s;
  int cnt = 1;
  dp4[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    dp3[u] = 0;
    for (int i = 0; i < adjl[u].size(); ++i) {
      int v = adjl[u][i].v;
      if (v != s0 && dad[v][2] == 0) {
        dad[v][2] = u;
        dad[v][1] = !adjl[u][i].dr;
        topo[++cnt] = v;
        q.push(v);
      }
    }
  }
  for (int i = cnt; i > 1; --i) {
    int u = topo[i];
    dp3[dad[u][2]] += dp3[u] + dad[u][1];
  }
  int mn = n - 1;
  for (int i = 1; i <= cnt; ++i) {
    int u = topo[i];
    mn = min(mn, dp3[u] + dp4[u]);
    for (int i = 0; i < adjl[u].size(); ++i) {
      int v = adjl[u][i].v;
      if (v == dad[u][2]) continue;
      dp4[v] = dp4[u] + dp3[u] - dp3[v] + (adjl[u][i].dr << 1) - 1;
    }
    dad[u][2] = 0;
  }
  return mn;
}
int calc(int s) {
  int mn[2] = {n << 1, n << 1};
  for (int i = 0; i < adjl[s].size(); ++i) {
    int u = adjl[s][i].v, dr = adjl[s][i].dr;
    int k = csub(u, s);
    k -= ((u == dad[s][0]) ? dp2[s] - dr : dp1[u] + 1 - (dr << 1));
    if (mn[0] > k) {
      mn[1] = mn[0];
      mn[0] = k;
    } else
      mn[1] = min(mn[1], k);
  }
  return dp1[s] + dp2[s] + mn[0] + mn[1];
}
void prs() {
  bfsanddp();
  ans = n - 1;
  for (int i = 2; i <= n; ++i) ans = min(ans, dp1[i] + dp2[i]);
  for (int i = 1; i <= n; ++i)
    if (adjl[i].size() > 1) ans = min(ans, calc(i));
}
void out() { cout << ans; }
void run() {
  in();
  prs();
  out();
}
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  run();
  return 0;
}
