#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
long long n, a, b, dp[N], cnt, ans, p, q, as = 1e17;
vector<pair<int, bool> > adj[N];
bool mark[N];
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    if (!mark[adj[v][i].first]) {
      if (!adj[v][i].second) cnt++;
      dfs(adj[v][i].first);
    }
  }
}
void df(int di, int par, int v) {
  mark[v] = true;
  if (di)
    dp[v] = dp[par] + 1;
  else
    dp[v] = dp[par] - 1;
  for (int i = 0; i < adj[v].size(); i++) {
    if (!mark[adj[v][i].first]) {
      df(adj[v][i].second, v, adj[v][i].first);
    }
  }
}
void sp(int x, int h, int v, long long p, long long q) {
  mark[v] = true;
  ans = min(ans, dp[x] - h + min(p, q));
  for (int i = 0; i < adj[v].size(); i++) {
    if (!mark[adj[v][i].first]) {
      if (adj[v][i].second)
        sp(x, h, adj[v][i].first, p, q + 1);
      else
        sp(x, h + 1, adj[v][i].first, p + 1, min(p, q));
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(make_pair(b, true));
    adj[b].push_back(make_pair(a, false));
  }
  dfs(0);
  dp[0] = cnt;
  for (int i = 1; i < n; i++) mark[i] = false;
  for (int i = 0; i < adj[0].size(); i++)
    df(adj[0][i].second, 0, adj[0][i].first);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) mark[j] = false;
    ans = 1e17;
    p = 0;
    q = 0;
    sp(i, 0, i, 0, 0);
    as = min(as, ans);
  }
  cout << as;
  return 0;
}
