#include <bits/stdc++.h>
using namespace std;
int i, j, k, m, n, l;
vector<int> a[3000 + 10];
int f[3000 + 10][3000 + 10];
int tot, mn;
void gao(int i, int pre, int now, int f0, int f1) {
  mn = min(mn, min(f0, f1) - now);
  for (int k = 0; k < (((int)(a[i]).size())); ++k) {
    int j = a[i][k];
    if (j != pre) {
      tot += f[j][i];
      gao(j, i, now + f[j][i], f0 + f[j][i], min(f0, f1) + 1 - f[j][i]);
    }
  }
}
int main() {
  while (cin >> n) {
    for (int i = (1); i <= (n); ++i) a[i].clear();
    memset(f, 0, sizeof(f));
    for (int i = 0; i < (n - 1); ++i) {
      scanf("%d%d", &j, &k);
      a[j].push_back(k), a[k].push_back(j);
      f[j][k]++;
    }
    int ans = n;
    for (int i = (1); i <= (n); ++i) {
      tot = 0, mn = n;
      gao(i, -1, 0, 0, 0);
      ans = min(ans, tot + mn);
    }
    cout << ans << endl;
  }
  return 0;
}
