#include <bits/stdc++.h>
using namespace std;
int chh;
const int N = 3005, INF = ~0U >> 2;
int n, m;
bool g[N][N];
vector<int> q[N];
int dfs(int u, int fa, int val) {
  int v, x = 0, res = 0;
  if (fa != -1) {
    if (g[u][fa])
      x = val + 1;
    else
      x = max(0, val - 1);
  }
  m = max(x, m);
  for (__typeof__((q[u]).begin()) it = (q[u]).begin(); it != (q[u]).end();
       it++) {
    v = *it;
    if (v == fa) continue;
    if (g[v][u]) res++;
    res += dfs(v, u, x);
  }
  return res;
}
int main() {
  int i, j, u, v, w, ans;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    q[u].push_back(v);
    q[v].push_back(u);
    g[u][v] = 1;
  }
  ans = INF;
  for (i = 1; i <= n; i++) {
    m = 0;
    w = dfs(i, -1, 0);
    w -= m;
    ans = min(ans, w);
  }
  printf("%d\n", ans);
  return 0;
}
