#include <bits/stdc++.h>
using namespace std;
template <class T>
void dumpBetween(const T& a, const T& b) {
  for (T it = a; it != b; it++) cout << *it << " ";
  cout << endl;
}
template <class T>
void dumpAll(const T& a) {
  dumpBetween((a).begin(), (a).end());
}
template <class T>
void minify(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void maxify(T& a, const T& b) {
  if (a < b) a = b;
}
int n;
vector<unsigned int> graph[3008];
vector<unsigned int> backgraph[3008];
void readInput() {
  scanf("%d", &(n));
  for (int _64 = 0; _64 < ((int)n - 1); _64++) {
    int a, b;
    scanf("%d%d", &(a), &(b));
    graph[(unsigned int)a].push_back(b);
    backgraph[(unsigned int)b].push_back(a);
  }
}
int chg[3008], chg1d[3008];
void dfs(unsigned int v, unsigned int parent) {
  ((void)0);
  chg[v] = 0;
  chg1d[v] = 0;
  for (unsigned int i = 0; i < ((unsigned int)(graph[v]).size()); i++) {
    unsigned int w = graph[v][i];
    if (w != parent) {
      dfs(w, v);
      chg[v] += chg[w];
      minify(chg1d[v], chg1d[w] + 1);
      ((void)0);
    }
  }
  for (unsigned int i = 0; i < ((unsigned int)(backgraph[v]).size()); i++) {
    unsigned int w = backgraph[v][i];
    if (w != parent) {
      dfs(w, v);
      chg[v] += chg[w] + 1;
      minify(chg1d[v], chg1d[w] - 1);
      ((void)0);
    }
  }
  ((void)0);
  ((void)0);
}
int minChangeFrom(unsigned int v) {
  ((void)0);
  dfs(v, -1);
  int c = 0;
  for (int i = 1; i < ((int)n + 1); i++) {
    if (i != v) {
      minify(c, chg1d[i]);
    }
  }
  return chg[v] + c;
}
void tc() {
  readInput();
  int res = 1 << 30;
  for (unsigned int i = 1; i < ((unsigned int)n + 1); i++) {
    minify(res, minChangeFrom(i));
  }
  printf("%d\n", res);
}
int main() { tc(); }
