#include <bits/stdc++.h>
using namespace std;
int n;
int Vt[7000];
int Next[7000];
int Co;
int H[7000];
int visit[4000];
int S[4000];
int L[4000];
int dp[4000];
void addlink(int u, int v) {
  Vt[++Co] = v;
  Next[Co] = H[u];
  H[u] = Co;
}
void duyet(int u) {
  visit[u] = 1;
  S[u] = 0;
  for (int idx = H[u]; idx; idx = Next[idx]) {
    int v = Vt[idx];
    if (visit[abs(v)]) continue;
    if (v < 0) {
      L[-v] = L[u] + 1;
      dp[-v] = dp[u];
      duyet(-v);
      S[u] += S[-v] + 1;
    } else {
      L[v] = L[u];
      dp[v] = min(L[v], dp[u] + 1);
      duyet(v);
      S[u] += S[v];
    }
  }
}
int main() {
  cin >> n;
  for (long long int i = 1; i <= n - 1; i++) {
    int a, b;
    cin >> a >> b;
    addlink(a, b);
    addlink(b, -a);
  }
  int MM = 1000000000;
  for (long long int i = 1; i <= n; i++) {
    for (long long int k = 1; k <= n; k++) {
      visit[k] = 0;
      S[k] = 0;
      L[k] = 0;
      dp[k] = 0;
    }
    L[i] = 0;
    dp[i] = 0;
    duyet(i);
    for (long long int j = 1; j <= n; j++)
      if (j != i) {
        if (S[i] - L[j] + dp[j] < MM) MM = S[i] - L[j] + dp[j];
      }
  }
  if (n == 1)
    cout << 0 << endl;
  else
    cout << MM << endl;
}
