#include <bits/stdc++.h>
using namespace std;
int n, val, ans = 32768;
const int N = 3e3;
vector<int> lvl, cnt;
vector<bool> vst;
vector<pair<int, int> > adj[N + 1];
void bfs(int idx) {
  queue<int> mq;
  mq.push(idx);
  lvl[idx] = 0, cnt[idx] = 0, vst[idx] = true;
  while (!mq.empty()) {
    idx = mq.front();
    mq.pop();
    for (int i = 0; i < adj[idx].size(); i++)
      if (!vst[adj[idx][i].first])
        lvl[adj[idx][i].first] = lvl[idx] + 1,
        cnt[adj[idx][i].first] = cnt[idx] + adj[idx][i].second,
        vst[adj[idx][i].first] = true, val += adj[idx][i].second,
        mq.push(adj[idx][i].first);
  }
}
void dfs(int idx, int minVal) {
  if (vst[idx]) {
    vst[idx] = false;
    minVal = min(minVal, 2 * cnt[idx] - lvl[idx]);
    ans = min(ans, val + minVal + lvl[idx] - 2 * cnt[idx]);
    for (int i = 0; i < adj[idx].size(); i++) dfs(adj[idx][i].first, minVal);
  }
}
int main() {
  int u, v;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    u--, v--;
    adj[u].push_back({v, 0});
    adj[v].push_back({u, 1});
  }
  lvl.resize(n, 0);
  cnt.resize(n, 0);
  vst.resize(n, false);
  for (int ii = 0; ii < n; ii++) {
    val = 0;
    bfs(ii);
    ans = min(ans, val);
    dfs(ii, 32768);
  }
  printf("%d \n", ans);
  return 0;
}
