#include <bits/stdc++.h>
using namespace std;
const int maxn = 3050;
int n, cnt, head[maxn], to[maxn * 2], nex[maxn * 2], w[maxn * 2];
void add(int x, int y, int z) {
  to[++cnt] = y;
  nex[cnt] = head[x];
  head[x] = cnt;
  w[cnt] = z;
}
int f[maxn], ans;
void dfs(int u, int fa) {
  f[u] = -0x3f3f3f3f;
  for (int i = head[u]; i; i = nex[i]) {
    int v = to[i];
    if (v == fa) continue;
    ans += w[i];
    dfs(v, u);
    int tmp = f[v];
    if (w[i] == 1)
      tmp++;
    else
      tmp--;
    f[u] = max(f[u], tmp);
    f[u] = max(f[u], w[i] == 1 ? 1 : -1);
  }
  if (f[u] == -0x3f3f3f3f) f[u] = 0;
}
signed main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y, 0);
    add(y, x, 1);
  }
  int res = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    memset(f, 0, sizeof(f));
    dfs(i, 0);
    for (int j = 1; j <= n; j++)
      if (i != j) res = min(res, ans - f[j]);
  }
  if (res == 0x3f3f3f3f) res = 0;
  cout << res << endl;
  return 0;
}
