#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3003;
int N, res = 1e8, cnt, mx;
vector<pair<int, int> > way[MAXN];
void dfs(int nd, int dad, int cur) {
  mx = max(mx, cur);
  for (vector<pair<int, int> >::iterator it = way[nd].begin();
       it != way[nd].end(); it++)
    if (it->first != dad) {
      cnt += it->second;
      dfs(it->first, nd, max(0, cur + 2 * (it->second) - 1));
    }
}
int main() {
  scanf(" %d", &N);
  for (int a, b, i = 1; i < N; i++) {
    scanf(" %d %d", &a, &b);
    way[a].push_back(pair<int, int>(b, 0));
    way[b].push_back(pair<int, int>(a, 1));
  }
  for (int i = 1; i <= N; i++) {
    cnt = 0, mx = 0;
    dfs(i, 0, 0);
    res = min(res, cnt - mx);
  }
  printf("%d\n", res);
  return 0;
}
