#include <bits/stdc++.h>
using namespace std;
vector<int> e[3100], t[3100];
int con[3100], rev[3100], f[3100];
int n, total;
void dfs(int u, int father) {
  int lim = e[u].size();
  for (int i = 0; i < lim; i++) {
    int v = e[u][i];
    if (v == father) continue;
    con[v] = con[u];
    rev[v] = rev[u];
    if (t[u][i] == -1) {
      total++;
      rev[v]++;
    } else
      con[v]++;
    f[v] = min(f[u], rev[v] - con[v]);
    dfs(v, u);
  }
}
int compute(int i) {
  memset(con, 0, sizeof(con));
  memset(rev, 0, sizeof(rev));
  memset(f, 0, sizeof(f));
  total = 0;
  dfs(i, -1);
  int ans = 1000000000;
  for (int j = 1; j <= n; j++) ans = min(ans, total - rev[j] + con[j] + f[j]);
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    t[u].push_back(1);
    e[v].push_back(u);
    t[v].push_back(-1);
  }
  int ans = 1000000000;
  for (int i = 1; i <= n; i++) ans = min(ans, compute(i));
  cout << ans << endl;
}
