#include <bits/stdc++.h>
using namespace std;
int f[3005], g[3005];
int n;
vector<pair<int, int> > mp[3005];
void dfs(int x, int pre) {
  int i, j, k, tmp;
  for (k = 0; k < mp[x].size(); k++) {
    i = mp[x][k].first;
    j = mp[x][k].second;
    if (pre == i) continue;
    dfs(i, x);
    f[x] += f[i] + j;
    tmp = g[i];
    if (j)
      tmp--;
    else
      tmp++;
    g[x] = min(tmp, g[x]);
  }
}
int main() {
  int i, j, k, ans = 100000;
  scanf("%d", &n);
  for (k = 1; k < n; k++) {
    scanf("%d%d", &i, &j);
    mp[i].push_back(make_pair(j, 0));
    mp[j].push_back(make_pair(i, 1));
  }
  for (i = 1; i <= n; i++) {
    memset(f, 0, sizeof(f));
    memset(g, 0, sizeof(g));
    dfs(i, 0);
    for (j = 1; j <= n; j++) ans = min(ans, g[j] + f[i]);
  }
  printf("%d\n", ans);
  return 0;
}
