#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > Adj[100009];
int n;
int res = 1000000000ll;
;
int f[100009], g[100009];
void dfs(int rt, int fa) {
  for (int i = 0; i < Adj[rt].size(); i++) {
    int v = Adj[rt][i].first;
    int p = Adj[rt][i].second;
    if (v == fa) continue;
    f[rt] += p;
    dfs(v, rt);
    f[rt] += f[v];
    int t = g[v];
    if (p)
      t = min(t - 1, -1);
    else
      t++;
    g[rt] = min(g[rt], t);
  }
}
int main() {
  cin >> n;
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    Adj[u].push_back(pair<int, int>(v, 0));
    Adj[v].push_back(pair<int, int>(u, 1));
  }
  for (int i = 1; i <= n; i++) {
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    dfs(i, 0);
    for (int j = 1; j <= n; j++) res = min(res, f[i] + g[j]);
  }
  cout << res << endl;
}
