#include <bits/stdc++.h>
using namespace std;
static const int INF = 0x7FFFFFFF;
static vector<vector<int> > g;
static vector<vector<int> > gp;
static int n;
static int dfs(int cur, int &running, int &mx, int parent) {
  int cost = 0, newRunning, newMx;
  running = 0;
  mx = 0;
  for (unsigned int i = 0; i < g[cur].size(); ++i) {
    if (g[cur][i] != parent) {
      cost += dfs(g[cur][i], newRunning, newMx, cur);
      running = max(running, newRunning - 1);
      mx = max(mx, newMx);
    }
  }
  for (unsigned int i = 0; i < gp[cur].size(); ++i) {
    if (gp[cur][i] != parent) {
      cost += dfs(gp[cur][i], newRunning, newMx, cur) + 1;
      running = max(running, newRunning + 1);
      mx = max(mx, newMx);
    }
  }
  mx = max(mx, running);
  return cost;
}
int main() {
  cin >> n;
  g.resize(n + 1);
  gp.resize(n + 1);
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    gp[b].push_back(a);
  }
  int best = INF;
  for (int i = 1; i <= n; ++i) {
    int cost, running = 0, mx = 0;
    cost = dfs(i, running, mx, -1);
    int newBest = cost - mx;
    if (newBest < best) best = newBest;
  }
  cout << best << endl;
  return 0;
}
