#include <bits/stdc++.h>
using namespace std;
int f[110000], t[110000], p[110000], u[110000], i, j, cc, n, x, y, ii, d,
    ret = 1000000000;
void addedge(int x, int y) {
  t[++ii] = y;
  p[ii] = f[x];
  f[x] = ii;
}
void dfs(int k, int cs) {
  d = max(d, cs);
  u[k] = i;
  int q = f[k];
  while (q) {
    if (u[t[q]] != i) {
      cc += 1 - q % 2;
      if (1 - q % 2 == 1)
        dfs(t[q], cs + 1);
      else
        dfs(t[q], max(cs - 1, 0));
    }
    q = p[q];
  }
}
int main(int argc, char* const argv[]) {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  for (i = 1; i <= n; i++) {
    cc = d = 0;
    dfs(i, 0);
    ret = min(ret, cc - d);
  }
  printf("%d\n", ret);
  return 0;
}
