#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000;
int n, javab = 0, parent[maxn], h, dp[maxn], d[maxn], s, a, b;
bool chek[maxn];
vector<int> t[maxn];
vector<pair<int, bool> > v[maxn];
vector<pair<int, int> > m;
void dfs(int x, int y, int r) {
  chek[x] = true;
  t[r].push_back(x);
  h = max(h, r);
  r++;
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i].first != y && chek[v[x][i].first] == false) {
      parent[v[x][i].first] = x;
      dfs(v[x][i].first, y, r);
    }
  r--;
}
int f(int x, int y) {
  for (int i = 0; i < n; i++) {
    parent[i] = 0;
    chek[i] = false;
    dp[i] = 0;
    d[i] = 0;
  }
  h = 0;
  parent[x] = y;
  dfs(x, y, 0);
  for (int i = h; i >= 0; i--) {
    for (int j = 0; j < t[i].size(); j++) {
      s = t[i][j];
      a = 0;
      b = 0;
      for (int k = 0; k < v[s].size(); k++)
        if (v[s][k].first != parent[s]) {
          a += d[v[s][k].first];
          d[s] += d[v[s][k].first];
          if (v[s][k].second == 1) {
            d[s]++;
            b++;
          }
        }
      dp[s] = d[s];
      for (int k = 0; k < v[s].size(); k++)
        if (v[s][k].first != parent[s]) {
          if (v[s][k].second == 1)
            dp[s] =
                min(dp[s], a - d[v[s][k].first] + b - 1 + dp[v[s][k].first]);
          else
            dp[s] =
                min(dp[s], a - d[v[s][k].first] + b + 1 + dp[v[s][k].first]);
        }
    }
    t[i].clear();
  }
  h = 0;
  parent[y] = x;
  dfs(y, x, 0);
  for (int i = h; i >= 0; i--) {
    for (int j = 0; j < t[i].size(); j++) {
      s = t[i][j];
      a = 0;
      b = 0;
      for (int k = 0; k < v[s].size(); k++)
        if (v[s][k].first != parent[s]) {
          a += d[v[s][k].first];
          d[s] += d[v[s][k].first];
          if (v[s][k].second == 1) {
            d[s]++;
            b++;
          }
        }
      dp[s] = d[s];
      for (int k = 0; k < v[s].size(); k++)
        if (v[s][k].first != parent[s]) {
          if (v[s][k].second == 1)
            dp[s] =
                min(dp[s], a - d[v[s][k].first] + b - 1 + dp[v[s][k].first]);
          else
            dp[s] =
                min(dp[s], a - d[v[s][k].first] + b + 1 + dp[v[s][k].first]);
        }
    }
    t[i].clear();
  }
  return dp[x] + dp[y];
}
int main() {
  int x, y;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(make_pair(y, 0));
    v[y].push_back(make_pair(x, 1));
    m.push_back(make_pair(x, y));
  }
  javab = n;
  for (int i = 0; i < (int)m.size(); i++)
    javab = min(javab, f(m[i].first, m[i].second));
  cout << javab << endl;
  return 0;
}
