#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 3100;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
vector<pair<long long, bool> > ger[maxn];
long long inv[maxn][maxn];
long long best[maxn][maxn];
long long dp[maxn][maxn];
long long rot;
void dfss(long long a, long long p = -1, long long in = 0) {
  inv[rot][a] = in;
  best[rot][a] = min(best[rot][a], inv[rot][a]);
  for (auto v : ger[a]) {
    if (v.first != p) {
      best[rot][v.first] = best[rot][a] + v.second;
      dp[rot][v.first] = dp[rot][a] - (!v.second);
      dfss(v.first, a, in + (!v.second));
    }
  }
}
long long dfs(long long a, long long p = -1) {
  long long ans = 0;
  for (auto v : ger[a]) {
    if (v.first != p) {
      ans += dfs(v.first, a);
      ans += (!v.second);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    ger[u].push_back(make_pair(v, 0));
    ger[v].push_back(make_pair(u, 1));
  }
  for (long long i = 0; i < n; i++) {
    rot = i;
    dp[rot][rot] = dfs(i);
    dfss(i);
  }
  long long ans = inf;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      ans = min(ans, best[i][j] + dp[i][j]);
    }
  }
  cout << ans;
}
