#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005, MAXM = MAXN * 2;
struct Edge {
  int to;
  int w;
  Edge *next;
};
int n, nE;
Edge E[MAXM], *V[MAXN];
void addEdge(int u, int v, bool w) {
  Edge *e = E + nE++;
  e->to = v;
  e->w = w;
  e->next = V[u];
  V[u] = e;
}
int total, tmax;
void dfs(int u, int pu, int tval) {
  if (tval < 0) tval = 0;
  tmax = max(tmax, tval);
  for (Edge *e = V[u]; e; e = e->next) {
    if (pu != e->to) {
      if (e->w) {
        ++total;
        dfs(e->to, u, tval + 1);
      } else {
        dfs(e->to, u, tval - 1);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0, a, b; i < n - 1; ++i) {
    scanf("%d%d", &a, &b);
    --a, --b;
    addEdge(a, b, 0);
    addEdge(b, a, 1);
  }
  int ans = 9999999;
  for (int i = 0; i < n; ++i) {
    total = tmax = 0;
    dfs(i, -1, 0);
    ans = min(ans, total - tmax);
  }
  printf("%d\n", ans);
  return 0;
}
