#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long long MAXN = 3e3 + 10;
long long n, u, v, mn, ans, res, dp[MAXN], d[MAXN];
vector<long long> vec;
vector<pair<long long, long long> > adj[MAXN];
long long dfs(long long u, long long p) {
  dp[u] = d[u];
  for (auto v : adj[u])
    if (v.first != p) {
      if (v.second == 1)
        d[v.first] = d[u] - 1;
      else
        d[v.first] = d[u] + 1;
      dfs(v.first, u), res += v.second, dp[u] = min(dp[u], dp[v.first]);
    }
  if (u == p)
    for (auto v : adj[u]) vec.push_back(dp[v.first]);
  sort(vec.begin(), vec.end()), mn = 0;
  if ((long long)vec.size()) {
    mn = min(mn, vec[0]);
    if (1 < (long long)vec.size()) mn = min(mn, vec[0] + vec[1]);
  }
  return mn;
}
void input() {
  cin >> n, ans = n;
  for (long long i = 0; i < n - 1; i++)
    cin >> u >> v, u--, v--, adj[u].push_back(make_pair(v, 0)),
        adj[v].push_back(make_pair(u, 1));
  return;
}
int32_t main() {
  input();
  for (long long i = 0; i < n; i++)
    res = 0, res += dfs(i, i), ans = min(ans, res), vec.clear(),
    memset(dp, 0, sizeof dp), memset(d, 0, sizeof d);
  return cout << ans << '\n', 0;
}
