#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > fedge, bedge;
int dp[1024 * 3][3];
int rec(int cur, int par, int type) {
  int &ret = dp[cur][type];
  if (ret == -1) {
    if (type == 0 || type == 1) {
      ret = 0;
      int sz, nx, best = 0;
      sz = fedge[cur].size();
      for (int i = 0; i < sz; i++) {
        nx = fedge[cur][i];
        if (nx != par) {
          ret += rec(nx, cur, 0);
          best = max(best, rec(nx, cur, 0) - rec(nx, cur, 1) - 1);
        }
      }
      sz = bedge[cur].size();
      for (int i = 0; i < sz; i++) {
        nx = bedge[cur][i];
        if (nx != par) {
          ret += 1 + rec(nx, cur, 0);
          best = max(best, rec(nx, cur, 0) - rec(nx, cur, 1) + 1);
        }
      }
      if (type == 1) ret -= best;
    } else {
      ret = rec(cur, par, 1);
      int pos = 0;
      int sz, nx, best = 0;
      sz = fedge[cur].size();
      for (int i = 0; i < sz; i++) {
        nx = fedge[cur][i];
        if (nx != par) {
          pos += rec(nx, cur, 0);
          best = max(best, rec(nx, cur, 0) - rec(nx, cur, 2));
        }
      }
      sz = bedge[cur].size();
      for (int i = 0; i < sz; i++) {
        nx = bedge[cur][i];
        if (nx != par) {
          pos += 1 + rec(nx, cur, 0);
          best = max(best, rec(nx, cur, 0) - rec(nx, cur, 2));
        }
      }
      pos -= best;
      ret = min(pos, ret);
    }
  }
  return ret;
}
int main() {
  int n, a, b, ans;
  while (scanf("%d", &n) != EOF) {
    fedge.clear();
    bedge.clear();
    fedge.resize(n + 1);
    bedge.resize(n + 1);
    for (int i = 0; i + 1 < n; i++) {
      cin >> a >> b;
      fedge[a].push_back(b);
      bedge[b].push_back(a);
    }
    ans = 1000000000;
    for (int i = 1; i <= n; i++) {
      memset(dp, -1, sizeof(dp));
      ans = min(ans, rec(i, 0, 2));
    }
    cout << ans << endl;
  }
  return 0;
}
