#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to;
  int dir;
};
int n;
vector<edge> G[3000];
int dfs(int v, int p) {
  int ret = 0;
  for (int i = 0; i < (int)(G[v].size()); i++) {
    edge &e = G[v][i];
    if (e.to == p) continue;
    ret += dfs(e.to, v);
    if (e.dir == -1) ++ret;
  }
  return ret;
}
int chRoot(int v, int p, int acc) {
  int ret = acc;
  for (int i = 0; i < (int)(G[v].size()); i++) {
    edge &e = G[v][i];
    if (e.to == p) continue;
    if (e.dir == 1)
      ret = min(ret, chRoot(e.to, v, acc + 1));
    else
      ret = min(ret, chRoot(e.to, v, acc - 1));
  }
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back((edge){b, 1});
    G[b].push_back((edge){a, -1});
  }
  if (n < 3) {
    puts("0");
    return 0;
  }
  int ret = 1 << 30;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(G[i].size()); j++) {
      int k = G[i][j].to;
      int dir = G[i][j].dir;
      if (dir == -1) continue;
      int acc1 = dfs(i, k);
      int acc2 = dfs(k, i);
      ret = min(ret, chRoot(i, k, acc1) + chRoot(k, i, acc2));
    }
  cout << ret << endl;
  return 0;
}
