#include <bits/stdc++.h>
const long long MOD = 1e9 + 7, INF = 1e18;
using namespace std;
int n, d_down[100000], d_up[100000];
vector<pair<int, int> > g[100000];
int dfs_down(int x, int p) {
  d_down[x] = 0;
  for (auto to : g[x])
    if (to.first != p) {
      int dir = (to.second == to.first);
      d_down[x] += dfs_down(to.first, x) + 1 - dir;
    }
  return d_down[x];
}
void dfs_up(int x, int p, int upper) {
  d_up[x] = upper;
  for (auto to : g[x])
    if (to.first != p) {
      int dir = (to.second == to.first);
      dfs_up(to.first, x,
             d_down[x] - (d_down[to.first] + 1 - dir) + dir + d_up[x]);
    }
}
int dfs_ans(int x, int p, int partial, int d_p, int last) {
  partial += d_down[x];
  int mx = partial;
  for (auto to : g[x])
    if (to.first != p) {
      int dir = (to.second == to.first);
      int new_d_p = min(d_p + dir, last + 1 - dir);
      mx = min(mx,
               dfs_ans(to.first, x,
                       partial - d_p + new_d_p - (d_down[to.first] + 1 - dir),
                       new_d_p, last + 1 - dir));
    }
  return mx;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u - 1].emplace_back(v - 1, v - 1);
    g[v - 1].emplace_back(u - 1, v - 1);
  }
  int ans = 1000000;
  for (int i = 0; i < n; i++) {
    dfs_down(i, -1);
    ans = min(ans, dfs_ans(i, -1, 0, 0, 0));
  }
  cout << ans;
}
