#include <bits/stdc++.h>
using namespace std;
long long n, x, y, mx, ans, jvb = 1e9;
vector<pair<int, int> > g[3090];
void dfs(long long x, long long par, long long m) {
  mx = max(mx, m);
  for (long long i = 0; i < g[x].size(); i++) {
    if (g[x][i].first != par) {
      if (g[x][i].second == 1)
        dfs(g[x][i].first, x, max((long long)0, m - 1));
      else {
        ans++;
        dfs(g[x][i].first, x, m + 1);
      }
    }
  }
}
int main() {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    cin >> x >> y;
    g[x].push_back(make_pair(y, 1));
    g[y].push_back(make_pair(x, 0));
  }
  for (long long i = 1; i < n + 1; i++) {
    ans = 0, mx = 0;
    dfs(i, -1, 0);
    jvb = min(jvb, ans - mx);
  }
  cout << jvb;
}
