#include <bits/stdc++.h>
using namespace std;
const long long int maxn = (3e3) + 10, mod = 1e9 + 7;
long long int n, cnt[2][maxn], res[maxn], num[maxn], ans = INT_MAX;
vector<long long int> v[maxn];
bool jah[maxn][maxn];
void pre_DFS(long long int x, long long int p) {
  for (auto u : v[x]) {
    if (u == p) continue;
    cnt[0][u] = cnt[0][x];
    if (jah[u][x]) cnt[0][u]++;
    cnt[1][u] = cnt[0][u];
    if (jah[u][x])
      cnt[1][u] = min(cnt[1][u], min(cnt[0][x], cnt[1][x]));
    else
      cnt[1][u] = min(cnt[1][u], min(cnt[0][x] + 1, cnt[1][x] + 1));
  }
  for (auto u : v[x]) {
    if (u == p) continue;
    num[u] = num[x];
    if (jah[u][x]) num[u]++;
    pre_DFS(u, x);
  }
  for (auto u : v[x]) {
    if (u == p) continue;
    res[x] += res[u];
    if (jah[u][x]) res[x]++;
  }
  if (p != -1) return;
  ans = min(res[x], ans);
  for (long long int i = 1; i <= n; i++) {
    ans = min(ans, res[x] - num[i] + cnt[1][i]);
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    jah[x][y] = 1;
  }
  for (long long int i = 1; i <= n; i++)
    res[i] = res[1] + cnt[0][i] - cnt[1][i];
  for (long long int i = 1; i <= n; i++) {
    memset(res, 0, sizeof res);
    memset(cnt, 0, sizeof cnt);
    memset(num, 0, sizeof num);
    pre_DFS(i, -1);
  }
  cout << ans << endl;
  return 0;
}
