#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
int dw[N], up[N], E[N][2], Mn;
vector<pair<int, int> > g[N];
void dfs_down(int v, int p) {
  dw[v] = 0;
  for (pair<int, int> u : g[v])
    if (u.first != p) dfs_down(u.first, v), dw[v] += dw[u.first] + u.second;
}
void dfs_up(int v, int p, int f = -1) {
  if (f != -1) {
    up[v] = up[p] + dw[p] - dw[v] + f - (f == 0);
  } else
    up[v] = 0;
  Mn = min(Mn, dw[v] + up[v]);
  for (pair<int, int> u : g[v])
    if (u.first != p) dfs_up(u.first, v, u.second ^ 1);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  if (n == 1) return cout << "0\n", 0;
  for (int i = 0; i < n - 1; i++) {
    cin >> E[i][0] >> E[i][1];
    g[E[i][0]].push_back({E[i][1], 0});
    g[E[i][1]].push_back({E[i][0], 1});
  }
  int ans = n;
  for (int i = 0; i < n - 1; i++) {
    Mn = n, dfs_down(E[i][0], E[i][1]), dfs_up(E[i][0], E[i][1]);
    int cur = Mn;
    Mn = n, dfs_down(E[i][1], E[i][0]), dfs_up(E[i][1], E[i][0]);
    cur += Mn;
    ans = min(ans, cur);
  }
  cout << ans << "\n";
}
