#include <bits/stdc++.h>
using namespace std;
const int MAXn = 3000;
vector<pair<int, bool> > adj[MAXn + 2];
int d[MAXn + 2][MAXn + 2], c[MAXn + 2][MAXn + 2], root;
bool mark[MAXn + 5];
void DFS(int v) {
  int sum = 0, Min = INT_MAX;
  mark[v] = true;
  for (int i = 0; i < (int)adj[v].size(); i++)
    if (!mark[adj[v][i].first]) {
      DFS(adj[v][i].first);
      sum += d[root][adj[v][i].first] + adj[v][i].second;
    }
  for (int i = 0; i < (int)adj[v].size(); i++)
    if (!mark[adj[v][i].first])
      Min = min(Min, c[root][adj[v][i].first] + !adj[v][i].second +
                         (sum - d[root][adj[v][i].first] - adj[v][i].second));
  d[root][v] = sum;
  Min = min(Min, d[root][v]);
  c[root][v] = Min;
  mark[v] = false;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    adj[u].push_back(make_pair(v, 0));
    adj[v].push_back(make_pair(u, 1));
  }
  for (int i = 0; i < n; i++) {
    root = i;
    DFS(i);
  }
  int Min = INT_MAX;
  for (int i = 0; i < n; i++) Min = min(d[i][i], Min);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) Min = min(Min, d[i][i] - d[i][j] + c[i][j]);
  cout << Min << endl;
  return 0;
}
