#include <bits/stdc++.h>
const int mod = 1e9 + 9;
int mul(int x, int y) { return 1LL * x * y % mod; }
int qpow(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = mul(res, x);
    y >>= 1;
    x = mul(x, x);
  }
  return res;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
using namespace std;
const int maxn = 3000 + 15;
vector<pair<int, int>> G[maxn];
int n, dp[maxn], d1[maxn], d2[maxn], mi = mod;
vector<pair<int, int>> edge;
inline void up(int &x, int v) { x = min(x, v); }
void DFS(int u, int fa) {
  dp[u] = 0;
  for (auto it : G[u]) {
    int v = it.first, c = it.second;
    if (v == fa) continue;
    d1[v] = d1[u] + c;
    d2[v] = d2[u] + (c ^ 1);
    DFS(v, u);
    dp[u] += dp[v] + c;
  }
  mi = min(mi, d2[u] - d1[u]);
}
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(make_pair(v, 0));
    G[v].push_back(make_pair(u, 1));
    edge.push_back(make_pair(u, v));
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = mod;
  for (auto del : edge) {
    int u = del.first, v = del.second;
    memset(dp, 0, sizeof(dp));
    memset(d1, 0, sizeof(d1));
    memset(d2, 0, sizeof(d2));
    mi = mod;
    DFS(u, v);
    int bs1 = dp[u] + mi;
    mi = mod;
    DFS(v, u);
    int bs2 = dp[v] + mi;
    ans = min(ans, bs1 + bs2);
  }
  cout << ans << endl;
  return 0;
}
