#include <bits/stdc++.h>
using namespace std;
const int MX = 3000 + 4;
vector<int> v[MX];
map<pair<int, int>, int> id;
int n, dpu[MX], dpd[MX], f[MX], h[MX][MX], ans[MX][MX];
bool mark[MX];
void get_dpd(int x) {
  mark[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int h = v[x][i];
    if (!mark[h]) {
      f[h] = x;
      get_dpd(h);
      if (id[pair<int, int>(x, h)] == 1)
        dpd[x] += dpd[h];
      else
        dpd[x] += dpd[h] + 1;
    }
  }
  mark[x] = false;
}
void get_dpu(int x) {
  mark[x] = true;
  if (x != 1) {
    if (id[pair<int, int>(x, f[x])] == 1)
      dpu[x] = dpu[f[x]] + dpd[f[x]] - dpd[x] - 1;
    else
      dpu[x] = dpu[f[x]] + 1 + dpd[f[x]] - dpd[x];
  }
  for (int i = 0; i < v[x].size(); i++) {
    int h = v[x][i];
    if (!mark[h]) get_dpu(h);
  }
  mark[x] = false;
}
void get_ans(int root, int x) {
  mark[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int r = v[x][i];
    if (!mark[r]) {
      if (id[pair<int, int>(x, r)] == 1)
        ans[root][r] = max(0, ans[root][x] - 1);
      else
        ans[root][r] = ans[root][x] + 1;
      get_ans(root, r);
    }
  }
  mark[x] = false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    id[pair<int, int>(x, y)] = 1;
    id[pair<int, int>(y, x)] = 2;
  }
  get_dpd(1);
  get_dpu(1);
  for (int i = 1; i <= n; i++) get_ans(i, i);
  int m = MX;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      m = min(dpu[i] + dpd[i] - ans[i][j], m);
    }
  cout << m;
}
