#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int inf = 1e9;
int n, dp[N], ans = inf, up[N];
vector<pair<int, int> > g[N];
vector<pair<int, int> > e;
void dfs(int v, int p) {
  dp[v] = 0;
  for (auto it : g[v])
    if (it.first != p) {
      dfs(it.first, v);
      dp[v] += (dp[it.first] + it.second);
    }
}
int go(int v, int p, int up = 0) {
  int ans = inf;
  ans = min(ans, dp[v] + up);
  for (auto it : g[v])
    if (it.first != p)
      ans = min(
          ans, go(it.first, v,
                  up + (dp[v] - (it.second + dp[it.first])) + (it.second ^ 1)));
  return ans;
}
int main() {
  scanf("%d", &n);
  if (n == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 1, a, b; i < n; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(make_pair(b, 0));
    g[b].push_back(make_pair(a, 1));
    e.push_back(make_pair(a, b));
  }
  for (auto it : e) {
    dfs(it.first, it.second);
    dfs(it.second, it.first);
    ans = min(ans, go(it.first, it.second) + go(it.second, it.first));
  }
  cout << ans;
  return 0;
}
