#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
int u[100100], d[100100], xi, xj, ei[100100], ej[100100], t;
bool valid(int i, int j) {
  return (i == xi && j == xj) || (j == xi && i == xj);
}
vector<int> f[100100], b[100100];
void dfs1(int i) {
  int j;
  d[i] = 0;
  u[i] = 1;
  for (j = 0; j < f[i].size(); j++)
    if (!valid(i, f[i][j]) && !u[f[i][j]]) {
      dfs1(f[i][j]);
      d[i] += d[f[i][j]];
    }
  for (j = 0; j < b[i].size(); j++)
    if (!valid(i, b[i][j]) && !u[b[i][j]]) {
      dfs1(b[i][j]);
      d[i] += d[b[i][j]] + 1;
    }
}
void dfs2(int i, int v) {
  int j;
  u[i] = 1;
  t = min(t, d[i] + v);
  for (j = 0; j < f[i].size(); j++)
    if (!valid(i, f[i][j]) && !u[f[i][j]])
      dfs2(f[i][j], v + d[i] - d[f[i][j]] + 1);
  for (j = 0; j < b[i].size(); j++)
    if (!valid(i, b[i][j]) && !u[b[i][j]])
      dfs2(b[i][j], v + d[i] - d[b[i][j]] - 1);
}
int main() {
  int i, j, k, n, r;
  for (scanf("%d", &n), k = n - 1; k--; scanf("%d%d", &i, &j), i--, j--,
                        f[i].push_back(j), b[j].push_back(i), ei[k] = i,
                        ej[k] = j)
    ;
  if (n == 1)
    r = 0;
  else {
    for (r = 100100, j = 0; j < n - 1; j++) {
      xi = ei[j];
      xj = ej[j];
      for (i = 0; i < n; u[i] = 0, i++)
        ;
      for (i = 0; i < n; i++)
        if (!u[i]) dfs1(i);
      for (i = 0; i < n; u[i] = 0, i++)
        ;
      for (k = 0, i = 0; i < n; i++)
        if (!u[i]) {
          t = 100100;
          dfs2(i, 0);
          k += t;
        }
      r = min(r, k);
    }
  }
  printf("%d\n", r);
  return 0;
}
