#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX, df = 3e5 + 7;
struct edge {
  long long to, typ, nxt;
} e[df << 2];
long long i, j, k, l, m, n, o = 1, p, q, r, s, t, u, v, w, x, y, z, dp[df], sum,
                            head[df], ans = inf;
inline void add(long long u, long long v, long long w) {
  e[++o] = (edge){v, w, head[u]}, head[u] = o;
}
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * y;
}
void dfs(long long u, long long fa) {
  for (long long i = head[u], v; i; i = e[i].nxt) {
    v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    dp[u] = min(dp[u], dp[v] + e[i].typ);
    if (e[i].typ == -1) sum++;
  }
}
int main() {
  n = read();
  for (long long i = (2); i <= (n); ++i) {
    long long u = read(), v = read();
    add(u, v, 1), add(v, u, -1);
  }
  for (long long i = (1); i <= (n); ++i) {
    memset(dp, 0, sizeof dp), sum = 0;
    dfs(i, 0);
    for (long long j = (1); j <= (n); ++j) ans = min(ans, sum + dp[j]);
  }
  return printf("%lld\n", ans), 0;
}
