#include <bits/stdc++.h>
using namespace std;
const int maxN = 3000 + 5;
const int inf = 1000 * 1000 * 100;
int mark[maxN];
vector<pair<int, int> > a[maxN];
int te, ans;
void dfs(int v, int cnt) {
  mark[v] = 1;
  ans = max(ans, cnt);
  for (int i = 0; i < a[v].size(); i++) {
    int u = a[v][i].first;
    if (mark[u]) continue;
    te += a[v][i].second;
    if (a[v][i].second)
      dfs(u, cnt + 1);
    else
      dfs(u, max(cnt - 1, 0));
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int d, k;
  for (int i = 1; i < n; i++) {
    cin >> d >> k;
    d--;
    k--;
    a[d].push_back(make_pair(k, 0));
    a[k].push_back(make_pair(d, 1));
  }
  int answer = inf;
  for (int i = 0; i < n; i++) {
    memset(mark, 0, sizeof mark);
    te = 0;
    ans = 0;
    dfs(i, 0);
    answer = min(answer, te - ans);
  }
  cout << answer << endl;
  return 0;
}
