#include <bits/stdc++.h>
using namespace std;
int tp, ck, n, i, s, d, ans = 3333;
vector<pair<int, int> > f[3333];
void dfs2(int x, int k, int r, int u) {
  tp += k;
  ck = max(ck, r);
  r = max(r, 0);
  for (int j = 0; j < f[x].size(); j++)
    if (f[x][j].first != u) {
      if (f[x][j].second == 1) {
        dfs2(f[x][j].first, 1, r + 1, x);
      }
      if (f[x][j].second == 0) {
        dfs2(f[x][j].first, 0, r - 1, x);
      }
    }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &s, &d);
    f[s].push_back(make_pair(d, 0));
    f[d].push_back(make_pair(s, 1));
  }
  for (i = 1; i <= n; i++) {
    tp = 0;
    ck = 0;
    dfs2(i, 0, 0, 0);
    ans = min(ans, tp - ck);
  }
  printf("%d\n", ans);
}
