#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int rev, mx;
vector<pair<int, int> > adj[N];
void dfs(int u, int num, int fa) {
  if (num < 0) num = 0;
  mx = max(mx, num);
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i].first;
    if (v == fa) continue;
    rev += adj[u][i].second;
    dfs(v, num + (adj[u][i].second == 0 ? -1 : 1), u);
  }
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) adj[i].clear();
    for (int i = 1; i < n; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      adj[a].push_back(make_pair(b, 0));
      adj[b].push_back(make_pair(a, 1));
    }
    int res = (1 << 30);
    for (int i = 1; i <= n; i++) {
      rev = 0, mx = 0;
      dfs(i, 0, -1);
      res = min(res, rev - mx);
    }
    printf("%d\n", res);
  }
  return 0;
}
