#include <bits/stdc++.h>
using namespace std;
const int Maxn = 3000 + 10;
int n, down[Maxn], dis[Maxn], par[Maxn], U, ans;
vector<int> adj[Maxn], ind[Maxn];
bool mark[Maxn];
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < (int)adj[v].size(); i++) {
    if (!mark[adj[v][i]]) {
      dis[adj[v][i]] = dis[v] + 1;
      down[adj[v][i]] = down[v];
      if (ind[v][i] == 1)
        down[adj[v][i]]++, dfs(adj[v][i]);
      else
        dfs(adj[v][i]), U++;
    }
  }
  return;
}
void dfs2(int v, int ansv, int numU, int numD) {
  mark[v] = true;
  ans = min(ans, ansv);
  for (int i = 0; i < (int)adj[v].size(); i++) {
    if (!mark[adj[v][i]] && adj[v][i] != par[v]) {
      if (ind[v][i] == 0)
        dfs2(adj[v][i], ansv - 1, numU + 1, numD);
      else {
        if (ansv + 1 <= ansv + numU - numD)
          dfs2(adj[v][i], ansv + 1, numU, numD + 1);
        else
          dfs2(adj[v][i], ansv + numU - numD, numU, numD);
      }
    }
  }
  return;
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    ind[u].push_back(1);
    ind[v].push_back(0);
  }
  dfs(0);
  ans = INT_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) mark[j] = false;
    v = i;
    while (1) {
      dfs2(v, U - (dis[i] - down[i]) + down[i], 0, 0);
      if (v == 0) break;
      v = par[v];
    }
  }
  printf("%d\n", ans);
  return 0;
}
