#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > g;
vector<vector<int> > sz;
int ans;
vector<int> sum;
int st[4000];
int cur_pos;
int dfs(int p, int v) {
  int ans = 0;
  for (int i = 0; i < g[v].size(); ++i)
    if (g[v][i].first != p) {
      ans += dfs(v, g[v][i].first);
      if (g[v][i].second == -1) ++ans;
    }
  return ans;
}
void dfs2(int p, int v, int s, int p1, int neg) {
  int cur_ans = s + p1;
  for (int i = 0; i < g[v].size(); ++i)
    if (g[v][i].first != p) cur_ans += sz[v][i];
  if (cur_ans < ans) ans = cur_ans;
  int pos = 0;
  while (p != -1 && g[v][pos].first != p) ++pos;
  for (int i = 0; i < g[v].size(); ++i)
    if (g[v][i].first != p) {
      int s1 = s;
      s += sum[v];
      if (p != -1) s -= sz[v][pos];
      s -= sz[v][i];
      if (g[v][i].second == 1) {
        if (p1 + 1 < neg)
          dfs2(v, g[v][i].first, s, p1 + 1, neg);
        else
          dfs2(v, g[v][i].first, s, neg, neg);
      } else {
        dfs2(v, g[v][i].first, s, p1, neg + 1);
      }
      s = s1;
    }
}
int main() {
  int n;
  cin >> n;
  g.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(make_pair(b - 1, 1));
    g[b - 1].push_back(make_pair(a - 1, -1));
  }
  sz.resize(n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < g[i].size(); ++j) {
      sz[i].push_back(dfs(i, g[i][j].first));
      if (g[i][j].second == -1) ++sz[i][(int)sz[i].size() - 1];
    }
  ans = n;
  sum.resize(n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < g[i].size(); ++j) sum[i] += sz[i][j];
  for (int i = 0; i < n; ++i) dfs2(-1, i, 0, 0, 0);
  cout << ans;
  return 0;
}
