#include <bits/stdc++.h>
using namespace std;
vector<int> g[3010];
vector<int> s[3010];
int root[3010];
int total[3010];
void dfs(int anc, int v, int a, int b) {
  root[v] = 0;
  for (int i = 0; i < (g[v].size()); ++i) {
    if ((v == a && b == g[v][i]) || g[v][i] == anc) continue;
    dfs(v, g[v][i], a, b);
  }
  for (int i = 0; i < (g[v].size()); ++i) {
    if ((v == a && b == g[v][i]) || g[v][i] == anc) continue;
    root[v] += root[g[v][i]] + !s[v][i];
  }
  total[v] = root[v];
  for (int i = 0; i < (g[v].size()); ++i) {
    if ((v == a && b == g[v][i]) || g[v][i] == anc) continue;
    total[v] = min(total[v], root[v] - root[g[v][i]] - !s[v][i] +
                                 total[g[v][i]] + s[v][i]);
  }
}
int main(int argc, char** argv) {
  int n;
  cin >> n;
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
    s[a].push_back(1);
    s[b].push_back(0);
  }
  dfs(-1, 0, -1, -1);
  int ans = total[0];
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (g[i].size()); ++j) {
      dfs(-1, i, i, g[i][j]);
      dfs(-1, g[i][j], g[i][j], i);
      ans = min(ans, total[i] + total[g[i][j]]);
    }
  cout << ans << endl;
}
