#include <bits/stdc++.h>
using namespace std;
const int N = 3030;
const int mod = 1e9 + 7;
int n, ans[2], res = INT_MAX;
int up[N], used[N];
pair<int, int> e[N];
vector<pair<int, int> > g[N];
void calc(int v) {
  used[v] = 1;
  up[v] = 0;
  int to, w;
  for (int i = 0; i < g[v].size(); ++i) {
    to = g[v][i].first;
    w = g[v][i].second;
    if (!used[to]) calc(to), up[v] += up[to] + w;
  }
}
void dfs(int v, int cnt, int k) {
  used[v] = 1;
  ans[k] = min(ans[k], up[v] + cnt);
  int sum = 0, to, w;
  for (int i = 0; i < g[v].size(); ++i) {
    to = g[v][i].first;
    w = g[v][i].second;
    if (!used[to]) sum += up[to] + w;
  }
  for (int i = 0; i < g[v].size(); ++i) {
    to = g[v][i].first;
    w = g[v][i].second;
    if (!used[to]) dfs(to, cnt + sum - (up[to] + w) + (1 - w), k);
  }
}
void solve(int x) {
  memset(used, 0, sizeof used);
  memset(up, 0, sizeof up);
  for (int j = 1; j <= n; ++j)
    if (!used[j]) calc(j);
  memset(used, 0, sizeof used);
  ans[0] = ans[1] = INT_MAX;
  int cmp = 0;
  for (int j = 1; j <= n; ++j)
    if (!used[j]) dfs(j, 0, cmp), cmp++;
  if (x == 1)
    res = min(res, ans[0]);
  else
    res = min(res, ans[0] + ans[1]);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> e[i].first >> e[i].second;
    g[e[i].first].push_back(make_pair(e[i].second, 0));
    g[e[i].second].push_back(make_pair(e[i].first, 1));
  }
  solve(1);
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= n; ++j) g[j].clear();
    for (int j = 1; j < n; ++j)
      if (i != j) {
        g[e[j].first].push_back(make_pair(e[j].second, 0));
        g[e[j].second].push_back(make_pair(e[j].first, 1));
      }
    solve(2);
  }
  cout << res;
  return 0;
}
