#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > g;
vector<bool> vis;
vector<int> f;
int go(int i) {
  vis[i] = 1;
  int ret = 0;
  for (int j = 0; j < g[i].size(); j++) {
    if (!vis[g[i][j].first]) {
      ret += g[i][j].second + go(g[i][j].first);
      f[i] = max(f[i], f[g[i][j].first] + (g[i][j].second ? 1 : -1));
    }
  }
  return ret;
}
int main() {
  int n;
  while (cin >> n) {
    g.clear();
    g.resize(n);
    for (int i = 1; i < n; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      ;
      g[a - 1].push_back({b - 1, 0});
      g[b - 1].push_back({a - 1, 1});
    }
    int res = 1e9;
    for (int i = 0; i < n; i++) {
      vis.clear();
      vis.resize(n, 0);
      f.clear();
      f.resize(n, 0);
      int rev = go(i);
      for (int j = 0; j < n; j++) res = min(res, rev - f[j]);
    }
    cout << res << endl;
  }
  return 0;
}
