#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3001;
const int INF = 0x3f3f3f3f;
int n, edgecnt;
int head[MAX_N], back[MAX_N];
struct edge {
  int u, v, w, next;
} edg[MAX_N << 1];
void addedge(int u, int v, int w) {
  edg[edgecnt] = (edge){u, v, w, head[u]};
  head[u] = edgecnt++;
}
void add(int u, int v) { addedge(u, v, 0), addedge(v, u, 1); }
void dfs(int fa, int u, int val, int &same) {
  back[u] = 0;
  for (int e = head[u]; ~e; e = edg[e].next) {
    int v = edg[e].v;
    if (v == fa) continue;
    dfs(u, v, val + (edg[e].w == 1 ? 1 : -1), same);
    back[u] += back[v] + edg[e].w;
  }
  same = max(same, val);
}
void solve() {
  if (1 == n) {
    puts("0");
    return;
  }
  int ret = INF;
  for (int i = 0; i < edgecnt; i += 2) {
    int same = -INF;
    int u = edg[i].u, v = edg[i].v;
    dfs(u, v, 0, same);
    int now = back[v] - same;
    same = -INF;
    dfs(v, u, 0, same);
    now += back[u] - same;
    ret = min(ret, now);
  }
  printf("%d\n", ret);
}
int main() {
  memset(head, -1, sizeof head);
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  solve();
  return 0;
}
