#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 7;
int n, E, D, up[N];
vector<pair<int, int> > e[N];
void dfs(int u, int fa) {
  D = max(D, up[u]);
  for (int i = (0), I = (((int)(e[u]).size())); i < I; ++i) {
    int v = e[u][i].first, s = e[u][i].second;
    if (v == fa) continue;
    E += (v == s);
    up[v] = max(0, up[u] + (v == s ? 1 : -1));
    dfs(v, u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (1), I = (n); i < I; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(make_pair(v, u));
    e[v].push_back(make_pair(u, u));
  }
  int ans = N;
  for (int i = (1), I = (n + 1); i < I; ++i) {
    up[i] = 0;
    E = D = 0;
    dfs(i, -1);
    ans = min(ans, E - D);
  }
  printf("%d", ans);
  return 0;
}
