#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
const int inf = 1000000007;
int n, u[N], v[N], size[N], up[N], down[N], dp[N];
vector<pair<int, int> > e[N];
void gao(int u, int pre) {
  size[u] = 1;
  down[u] = 0;
  up[u] = 0;
  dp[u] = 0;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first, w = e[u][i].second;
    if (v == pre) continue;
    gao(v, u);
    size[u] += size[v];
    down[u] += down[v] + 1 - w;
    up[u] += up[v] + w;
  }
}
int ret;
void cao(int u, int pre) {
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i].first, w = e[u][i].second;
    if (v == pre) continue;
    dp[v] += dp[u];
    dp[v] += down[u] - down[v];
    if (w == 1)
      dp[v]++;
    else
      dp[v]--;
    cao(v, u);
    ret = min(ret, down[v] + dp[v]);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> u[i] >> v[i];
    e[u[i]].push_back(make_pair(v[i], 1));
    e[v[i]].push_back(make_pair(u[i], 0));
  }
  if (n <= 2) {
    puts("0");
    return 0;
  }
  int ans = n;
  for (int i = 0; i < n - 1; i++) {
    gao(u[i], v[i]);
    ret = down[u[i]];
    cao(u[i], v[i]);
    int cnt = ret;
    gao(v[i], u[i]);
    ret = down[v[i]];
    cao(v[i], u[i]);
    cnt += ret;
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
