#include <bits/stdc++.h>
using namespace std;
const int maxn = 3100;
vector<int> adj[maxn];
vector<int> readj[maxn];
bool mark[maxn];
int ch[maxn];
queue<int> Q;
int n;
int f(int v, int U) {
  mark[U] = true;
  int re = 0;
  while (!Q.empty()) {
    int V = Q.front();
    mark[V] = true;
    Q.pop();
    for (int i = 0; i < adj[V].size(); i++) {
      int u = adj[V][i];
      if (mark[u] == false) {
        mark[u] = true;
        Q.push(u);
      }
    }
    for (int i = 0; i < readj[V].size(); i++) {
      int u = readj[V][i];
      if (mark[u] == false) {
        re++;
        mark[u] = true;
        Q.push(u);
      }
    }
  }
  ch[v] = re;
  int ans = re;
  fill(mark, mark + maxn, false);
  Q.push(v);
  mark[v] = true;
  mark[U] = true;
  while (!Q.empty()) {
    int V = Q.front();
    Q.pop();
    mark[V] = true;
    for (int i = 0; i < readj[V].size(); i++) {
      int u = readj[V][i];
      if (mark[u] == false) {
        mark[u] = true;
        ch[u] = ch[V] - 1;
        if (ch[u] < ans) ans = ch[u];
        Q.push(u);
      }
    }
    for (int i = 0; i < adj[V].size(); i++) {
      int u = adj[V][i];
      if (mark[u] == false) {
        mark[u] = true;
        ch[u] = ch[V] + 1;
        if (ch[u] < ans) ans = ch[u];
        Q.push(u);
      }
    }
  }
  return ans;
}
int main() {
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    readj[b].push_back(a);
  }
  int ans = maxn;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < adj[i].size(); j++) {
      fill(mark, mark + maxn, false);
      int v = i;
      int u = adj[v][j];
      Q.push(u);
      int U = f(u, v);
      fill(mark, mark + maxn, false);
      Q.push(v);
      int V = f(v, u);
      ans = min(ans, V + U);
    }
  }
  cout << ans << endl;
}
