#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, w, next;
} edge[10000];
int head[5000], cnt, ans;
int dp[5000];
void addedge(int u, int v, int w) {
  edge[cnt].v = v;
  edge[cnt].w = w;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}
void dfs(int u, int fa) {
  int i, v;
  dp[u] = 0;
  for (i = head[u]; i != -1; i = edge[i].next) {
    v = edge[i].v;
    if (v == fa) continue;
    dfs(v, u);
    dp[u] += dp[v];
    dp[u] += edge[i].w;
  }
  return;
}
int s;
void dfs2(int u, int fa, int minn, int now) {
  int i, v;
  if (dp[s] + minn - now < ans) ans = dp[s] + minn - now;
  for (i = head[u]; i != -1; i = edge[i].next) {
    v = edge[i].v;
    if (v == fa) continue;
    if (edge[i].w == 0) {
      if (now - 1 < minn)
        dfs2(v, u, now - 1, now - 1);
      else
        dfs2(v, u, minn, now - 1);
    } else
      dfs2(v, u, minn, now + 1);
  }
}
int main() {
  int n, i, u, v;
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  cnt = 0;
  ans = n;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v, 0);
    addedge(v, u, 1);
  }
  for (i = 1; i <= n; i++) {
    dfs(i, 0);
    if (dp[i] < ans) {
      ans = dp[i];
      s = i;
    }
  }
  dfs(s, 0);
  dfs2(s, 0, 0, 0);
  printf("%d\n", ans);
  return 0;
}
