#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > g;
int ans, c1, c2;
void dfs(int v, int p, int c) {
  c1 = max(c1, c);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first, ves = g[v][i].second;
    if (to != p) {
      int cc = max(0, c + 2 * ves - 1);
      c2 += ves;
      dfs(to, v, cc);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  ans = n;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a - 1].push_back(make_pair(b - 1, 0));
    g[b - 1].push_back(make_pair(a - 1, 1));
  }
  for (int i = 0; i < n; i++) {
    c2 = c1 = 0;
    dfs(i, -1, 0);
    ans = min(ans, c2 - c1);
  }
  printf("%d", ans);
  return 0;
}
