#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > g[55000];
long long anss, s, n, ans2, ans = 1e18;
void dfs(long long v, long long p, long long ans_p, int f) {
  if (f == 2) {
    cerr << -1 << endl;
    return;
  }
  ans2 = max(ans2, ans_p);
  for (auto to : g[v]) {
    if (to.first == p) continue;
    if (ans_p + to.second < 0)
      dfs(to.first, v, 0, 0);
    else
      dfs(to.first, v, ans_p + to.second, 0);
    if (to.second > 0) anss++;
  }
  if (f == -1) ans = min(ans, anss - ans2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    g[--x].push_back({--y, -1});
    g[y].push_back({x, 1});
  }
  for (int i = 0; i < n; ++i) {
    anss = 0;
    ans2 = 0;
    dfs(i, i, 0, -1);
  }
  cout << ans;
}
