#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3010;
vector<pair<int, int> > e[MAXN];
int n;
int memo[MAXN];
int go(int i, int f) {
  int res = 0;
  for (int x = 0; x < (int)e[i].size(); x++) {
    int j = e[i][x].first, d = e[i][x].second;
    if (j != f) res += go(j, i) + (d == 1 ? 0 : 1);
  }
  return memo[i] = res;
}
int go2(int i, int f, int num) {
  int res[3] = {0, n, n};
  for (int x = 0; x < (int)e[i].size(); x++) {
    int j = e[i][x].first, d = e[i][x].second;
    if (j != f) {
      int tmp0 = memo[j] + (d == 1 ? 0 : 1);
      int tmp1 = go2(j, i, 2) + (d == 1 ? 1 : 0);
      int nres[3] = {0, n, n};
      nres[0] = res[0] + tmp0;
      nres[1] = min(res[1] + tmp0, res[0] + tmp1);
      if (num > 2)
        nres[2] = min(nres[2] + tmp0, res[1] + tmp1 - (d == 1 ? 1 : 0));
      for (int y = 0; y < (int)num; y++) res[y] = nres[y];
    }
  }
  int rtv = min(res[0], res[1]);
  if (num > 2) rtv = min(rtv, res[2]);
  if (num == 3) {
    int res[3] = {0, n, n};
    for (int x = e[i].size() - 1; x >= 0; x--) {
      int j = e[i][x].first, d = e[i][x].second;
      if (j != f) {
        int tmp0 = memo[j] + (d == 1 ? 0 : 1);
        int tmp1 = go2(j, i, 2) + (d == 1 ? 1 : 0);
        int nres[3] = {0, n, n};
        nres[0] = res[0] + tmp0;
        nres[1] = min(res[1] + tmp0, res[0] + tmp1);
        if (num > 2)
          nres[2] = min(nres[2] + tmp0, res[1] + tmp1 - (d == 1 ? 1 : 0));
        for (int y = 0; y < (int)num; y++) res[y] = nres[y];
      }
    }
    rtv = min(rtv, res[0]);
    rtv = min(rtv, res[1]);
    rtv = min(rtv, res[2]);
  }
  return rtv;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    e[a].push_back(pair<int, int>(b, +1));
    e[b].push_back(pair<int, int>(a, -1));
  }
  int ans = n;
  for (int i = 0; i < (int)n; i++) {
    int curr = go(i, -1);
    ans = min(ans, curr);
  }
  for (int i = 0; i < (int)n; i++) {
    go(i, -1);
    int curr = go2(i, -1, 3);
    ans = min(ans, curr);
  }
  printf("%d\n", ans);
  return 0;
}
