#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 10;
vector<pair<int, int> > graph[N], edge;
bool mark[N];
int num[N], mini[N];
void DFS(int v) {
  mark[v] = true;
  int t = INT_MIN;
  for (int i = 0; i < (int)graph[v].size(); i++) {
    int u = graph[v][i].first;
    if (!mark[u]) {
      DFS(u);
      num[v] += num[u];
      int x = graph[v][i].second;
      if (x == 1) num[v]++;
      t = max(t, num[u] - mini[u] + x);
    }
  }
  t = max(t, 0);
  mini[v] = num[v] - t;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(make_pair(b, -1));
    graph[b].push_back(make_pair(a, 1));
    edge.push_back(make_pair(a, b));
  }
  int ans = INT_MAX;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      mark[j] = false;
      num[j] = 0;
      mini[j] = 0;
    }
    int x = edge[i].first, y = edge[i].second;
    mark[y] = true;
    DFS(x);
    DFS(y);
    ans = min(ans, mini[x] + mini[y]);
  }
  if (n == 1) ans = 0;
  cout << ans << endl;
}
