#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const int inf = 2000000000;
vector<pair<int, int> > g[N];
int first, second, i, n, q, w, r, f, ans = inf;
void dfs1(int v, int pr = -1) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i].first != pr) {
      r += g[v][i].second;
      dfs1(g[v][i].first, v);
    }
}
void dfs2(int v, int pr = 0, int f = 0) {
  ans = min(ans, r - f);
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i].first != pr) {
      if (g[v][i].second)
        dfs2(g[v][i].first, v, f + 1);
      else
        dfs2(g[v][i].first, v, max(f - 1, 0));
    }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> q >> w;
    g[q].push_back(make_pair(w, 0));
    g[w].push_back(make_pair(q, 1));
  }
  for (i = 1; i <= n; i++) {
    r = 0;
    dfs1(i);
    dfs2(i);
  }
  cout << ans << endl;
}
