#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline string gets() {
  char ch[1000000];
  scanf("%s", ch);
  return ch;
}
template <class P, class Q>
inline P smin(P &a, Q b) {
  if (b < a) a = b;
  return a;
}
template <class P, class Q>
inline P smax(P &a, Q b) {
  if (a < b) a = b;
  return a;
}
const int MAX_LG = 17;
const int maxn = 4e5 + 10;
const int base = 29;
const int mod = 1e9 + 9;
const int INF = 1e9;
const int maxq = 2e5 + 10;
vector<pair<int, int> > g[maxn];
int res = 1e9;
int up[maxn], di[maxn];
inline int dfs(int v, int pr, int down) {
  di[v] = min(di[pr] + down, up[pr]);
  up[v] = up[pr] + !down;
  int tot = 0;
  for (int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].first;
    if (u == pr) continue;
    tot += dfs(u, v, !g[v][i].second) + g[v][i].second;
  }
  return tot;
}
int n;
inline void check(int v) {
  memset(up, 0, (n + 1) * sizeof(up[0]));
  memset(di, 0, (n + 1) * sizeof(di[0]));
  int tot = 0;
  for (int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].first;
    tot += dfs(u, v, !g[v][i].second) + g[v][i].second;
  }
  for (int i = 1; i <= n; i++) {
    if (i == v) continue;
    res = min(res, tot - up[i] + di[i]);
  }
}
int32_t main() {
  n = in();
  if (n == 1) return cout << 0 << "\n", 0;
  for (int i = 0; i < n - 1; i++) {
    int v = in(), u = in();
    g[v].push_back({u, 0}), g[u].push_back({v, 1});
  }
  for (int i = 1; i <= n; i++) check(i);
  cout << res << "\n";
}
