#include <bits/stdc++.h>
using namespace std;
const int MX = 3009, INF = 1e9 + 7;
vector<pair<int, int> > adj[MX];
int dp[2][MX], mrk[MX];
pair<int, int> edge[MX];
void DFS(int u, int prev) {
  mrk[u] = 1;
  int num = 0;
  for (auto v : adj[u]) {
    if (v.first != prev) {
      DFS(v.first, u);
      num += dp[0][v.first] + v.second;
    }
  }
  dp[1][u] = dp[0][u] = num;
  for (auto v : adj[u]) {
    if (v.first != prev) {
      dp[1][u] =
          min(dp[0][u] - dp[0][v.first] - v.second + !v.second + dp[1][v.first],
              dp[1][u]);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    edge[i] = {u, v};
    adj[u].push_back({v, 0});
    adj[v].push_back({u, 1});
  }
  int ans = INF;
  for (int i = 1; i < n; i++) {
    int u = edge[i].first, v = edge[i].second;
    int num = 0;
    DFS(u, u);
    num += dp[1][v];
    DFS(v, v);
    num += dp[1][u];
    ans = min(ans, num);
  }
  DFS(1, 1);
  ans = min(ans, dp[1][1]);
  cout << ans;
  return 0;
}
