#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
vector<pair<int, int> > v[N];
int a[N], b[N], cnt, res;
void dfs(int x, int pr, int tmp) {
  res = max(res, tmp);
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i].first != pr) {
      cnt += v[x][i].second;
      dfs(v[x][i].first, x, max(0, tmp + v[x][i].second * 2 - 1));
    }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(make_pair(y, 0));
    v[y].push_back(make_pair(x, 1));
  }
  int ans = n;
  for (int i = 0; i < n; i++) {
    cnt = res = 0;
    dfs(i, i, 0);
    ans = min(ans, cnt - res);
  }
  cout << ans << endl;
  return 0;
}
