#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 10;
struct Edge {
  int u, to, next, dir;
} edge[maxn << 1];
int head[maxn], E, cnt[maxn];
void init() {
  memset(head, -1, sizeof(head));
  E = 0;
}
void adde(int u, int to, int dir) {
  edge[E].u = u;
  edge[E].to = to;
  edge[E].dir = dir;
  edge[E].next = head[u];
  head[u] = E++;
}
int mx;
void dfs(int pre, int u, int val) {
  cnt[u] = 0;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int to = edge[i].to;
    if (to == pre) continue;
    dfs(u, to, val + (edge[i].dir == 1 ? 1 : -1));
    cnt[u] += cnt[to] + edge[i].dir;
  }
  mx = max(mx, val);
}
int main() {
  init();
  int n, u, to;
  scanf("%d", &n);
  if (n == 1) return puts("0"), 0;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &to);
    adde(u, to, 0);
    adde(to, u, 1);
  }
  int ans = 1 << 30;
  for (int i = 0; i < E; i += 2) {
    u = edge[i].u;
    to = edge[i].to;
    mx = -(1 << 30);
    dfs(u, to, 0);
    int now = cnt[to] - mx;
    mx = -(1 << 30);
    dfs(to, u, 0);
    now += cnt[u] - mx;
    ans = min(ans, now);
  }
  printf("%d\n", ans);
  return 0;
}
