#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3001;
vector<pair<int, bool> > g[MAXN];
int n;
int cur, pen, cc;
int result = 4000;
void dfs_cnt(int v, int p = -1) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i].first != p) {
      if (g[v][i].second == 0) cur++;
      dfs_cnt(g[v][i].first, v);
    }
}
void dfs_fin(int v, int p = -1, int curP = 0) {
  result = ((cur - curP < result) ? (cur - curP) : (result));
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i].first != p) {
      bool r = false;
      if (g[v][i].second == 0)
        dfs_fin(g[v][i].first, v, curP + 1);
      else
        dfs_fin(g[v][i].first, v, max(curP - 1, 0));
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int f, t;
    cin >> f >> t;
    f--, t--;
    g[f].push_back(make_pair(t, 1));
    g[t].push_back(make_pair(f, 0));
  }
  for (int i = 0; i < n; i++) {
    cur = 0;
    dfs_cnt(i);
    dfs_fin(i);
  }
  cout << result << endl;
}
