#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e3 + 8;
const long long maxm = 1e7 + 8;
struct EDGE {
  int u, v, w, next;
} edge[maxn << 1];
int edge_cnt = 1;
int head[maxn];
int dp[maxn];
int dif;
void init() { memset(head, -1, sizeof(head)); }
void add_edge(int u, int v, int w) {
  edge[edge_cnt] = (EDGE){u, v, w, head[u]};
  head[u] = edge_cnt++;
}
void dfs(int u, int fa, int cost) {
  dp[u] = 0;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    if (v == fa) continue;
    dfs(v, u, cost + edge[i].w);
    dp[u] += dp[v] + (edge[i].w == 1);
  }
  dif = max(dif, cost);
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  if (n == 1) {
    printf("%d", 0);
    return 0;
  }
  init();
  while (--n) {
    scanf("%d%d", &u, &v);
    add_edge(u, v, -1);
    add_edge(v, u, 1);
  }
  int ans = maxn;
  for (int i = 1; i < edge_cnt; i += 2) {
    int u = edge[i].u;
    int v = edge[i].v;
    dif = 0;
    int reve = 0;
    dfs(u, v, 0);
    reve = dp[u] - dif;
    dif = 0;
    dfs(v, u, 0);
    reve += dp[v] - dif;
    ans = min(ans, reve);
  }
  printf("%d", ans);
  return 0;
}
