#include <bits/stdc++.h>
using namespace std;
const int N = 3001;
int n, a, b, ans = 1e9, cost, mark[N], dp[N];
vector<pair<int, int> > v[N];
void dfs(int x, int y) {
  for (int i = 0; i < v[x].size(); ++i) {
    if (v[x][i].first != y) {
      cost += v[x][i].second;
      if (v[x][i].second)
        dp[v[x][i].first] = dp[x] - 1;
      else
        dp[v[x][i].first] = min(dp[x] + 1, 0);
      dfs(v[x][i].first, x);
    }
  }
}
int solve(int x) {
  memset(mark, 0, sizeof mark);
  memset(dp, 0, sizeof dp);
  int ret = 1e9;
  cost = 0;
  dfs(x, 0);
  for (int i = 1; i <= n; ++i) ret = min(ret, cost + dp[i]);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> a >> b;
    v[a].push_back(make_pair(b, 0));
    v[b].push_back(make_pair(a, 1));
  }
  for (int i = 1; i <= n; ++i) ans = min(ans, solve(i));
  cout << ans << '\n';
}
