#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
const int M = 11;
const int INF = 1 << 30;
const double EPS = 1e-8;
const int MOD = 1000000007LL;
int n, tot[N];
vector<int> edge[N], edge2[N];
int dfs(int u, int fa) {
  int num = 0, sz;
  sz = edge[u].size();
  for (int i = 0; i < sz; i++) {
    int v = edge[u][i];
    if (v == fa) {
      continue;
    }
    num += dfs(v, u);
  }
  sz = edge2[u].size();
  for (int i = 0; i < sz; i++) {
    int v = edge2[u][i];
    if (v == fa) {
      continue;
    }
    num += dfs(v, u) + 1;
  }
  return num;
}
void init() {
  memset(tot, 0, sizeof(tot));
  for (int i = 0; i < n; i++) {
    edge[i].clear();
    edge2[i].clear();
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    edge[u].push_back(v);
    edge2[v].push_back(u);
  }
  for (int u = 0; u < n; u++) {
    int sz;
    sz = edge[u].size();
    for (int i = 0; i < sz; i++) {
      int v = edge[u][i];
      int num = dfs(v, u);
      tot[u] += num;
    }
    sz = edge2[u].size();
    for (int i = 0; i < sz; i++) {
      int v = edge2[u][i];
      int num = dfs(v, u) + 1;
      tot[u] += num;
    }
  }
}
int dfs2(int u, int fa) {
  int sz, ret = tot[u];
  sz = edge[u].size();
  for (int i = 0; i < sz; i++) {
    int v = edge[u][i];
    if (v == fa) {
      continue;
    }
    ret = min(ret, dfs2(v, u));
  }
  sz = edge2[u].size();
  for (int i = 0; i < sz; i++) {
    int v = edge2[u][i];
    if (v == fa) {
      continue;
    }
    ret = min(ret, dfs2(v, u));
  }
  return ret;
}
void solve() {
  int ans = INF;
  for (int i = 0; i < n; i++) {
    ans = min(ans, tot[i]);
  }
  for (int i = 0; i < n; i++) {
    vector<int> p;
    int sz;
    sz = edge[i].size();
    for (int j = 0; j < sz; j++) {
      int v = edge[i][j];
      p.push_back(dfs2(v, i));
    }
    sz = edge2[i].size();
    for (int j = 0; j < sz; j++) {
      int v = edge2[i][j];
      p.push_back(dfs2(v, i));
    }
    if (p.size() <= 1) {
      continue;
    }
    sort(p.begin(), p.end());
    int tmp = p[0] + p[1] - tot[i];
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}
int main() {
  while (cin >> n) {
    init();
    solve();
  }
  return 0;
}
