#include <bits/stdc++.h>
using namespace std;
int to[40000], val[40000], tip[40000];
vector<int> adj[4000];
int func(int v, int p) {
  int r = 0;
  for (int i = 0; i < adj[v].size(); ++i) {
    int w = to[adj[v][i]];
    if (w == p) continue;
    r += func(w, v);
    r += tip[adj[v][i]];
  }
  return r;
}
int rec(int v, int p) {
  int sum = 0;
  for (int i = 0; i < adj[v].size(); ++i) {
    int w = to[adj[v][i]];
    if (w == p) continue;
    sum += val[adj[v][i]];
  }
  int bst = sum;
  for (int i = 0; i < adj[v].size(); ++i) {
    int w = to[adj[v][i]];
    if (w == p) continue;
    bst = min(bst, rec(w, v) + (1 - tip[adj[v][i]]) + (sum - val[adj[v][i]]));
  }
  return bst;
}
int ls[4000];
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    to[cnt] = b, tip[cnt] = 0;
    adj[a].push_back(cnt), cnt++;
    to[cnt] = a, tip[cnt] = 1;
    adj[b].push_back(cnt), cnt++;
  }
  int rsp = 1000000000;
  for (int i = 1; i < n + 1; ++i) {
    int sum = 0;
    for (int j = 0; j < adj[i].size(); ++j) {
      int w = to[adj[i][j]];
      val[adj[i][j]] = func(w, i) + tip[adj[i][j]];
      sum += val[adj[i][j]];
    }
    rsp = min(rsp, sum);
  }
  for (int i = 1; i < n + 1; ++i) {
    int sum = 0;
    int m = adj[i].size();
    for (int j = 0; j < m; ++j) {
      sum += val[adj[i][j]];
      int w = to[adj[i][j]];
      ls[j] = (rec(w, i) + (1 - tip[adj[i][j]])) - val[adj[i][j]];
    }
    if (m > 1) {
      sort(ls, ls + m);
      rsp = min(rsp, sum + ls[0] + ls[1]);
    }
  }
  printf("%d\n", rsp);
  return 0;
}
