#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > g;
vector<int> riht, cap2, revs, st;
vector<bool> used;
int ans, all;
void dfs(int v, int p) {
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first, ves = g[v][i].second;
    if (to != p) {
      all += ves;
      riht[to] = riht[v] - (ves - 1);
      revs[to] = revs[v] + ves;
      cap2[to] = min(cap2[v], revs[to] - riht[to]);
      dfs(to, v);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  cap2.resize(n);
  riht.resize(n);
  revs.resize(n);
  st.resize(n, 0);
  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));
    st[b - 1]++;
  }
  for (int i = 0; i < n; i++) {
    if (!st[i]) {
      cap2.assign(n, 0);
      riht.assign(n, 0);
      revs.assign(n, 0);
      all = 0;
      dfs(i, -1);
      for (int j = 0; j < n; j++)
        ans = min(ans, all - revs[j] + riht[j] + cap2[j]);
    }
  }
  printf("%d", ans);
  return 0;
}
