#include <bits/stdc++.h>
using namespace std;
int p[9000], e[9000], ne[9000], ec, n, v[9000], vc, f[9000], s, t;
void adde(int a, int b) {
  e[++ec] = b;
  ne[ec] = p[a];
  p[a] = ec;
  e[++ec] = a;
  ne[ec] = p[b];
  p[b] = ec;
  f[ec] = 1;
}
void dfs(int a, int z) {
  v[a] = vc;
  t = max(t, z);
  for (int i = p[a]; i; i = ne[i])
    if (v[e[i]] != vc) {
      s += f[i];
      dfs(e[i], max(0, z + (f[i] ? 1 : -1)));
    }
}
int main() {
  int i, j, ans, a, b;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    adde(a, b);
  }
  ans = n;
  for (i = 1; i <= n; i++) {
    s = t = 0;
    vc++;
    dfs(i, 0);
    ans = min(ans, s - t);
  }
  printf("%d\n", ans);
}
