#include <bits/stdc++.h>
using namespace std;
int n, m, c1, c2;
int sz[3002];
vector<pair<int, int> > adj[3002];
void dfs(int node, int bef, int c) {
  c1 = max(c1, c);
  for (int i = 0; i < sz[node]; i++)
    if (adj[node][i].first != bef) {
      int cc = max(0, c + 2 * adj[node][i].second - 1);
      c2 += adj[node][i].second;
      dfs(adj[node][i].first, node, cc);
    }
}
int main() {
  scanf("%d", &n);
  m = n - 1;
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    adj[x].push_back(pair<int, int>(y, 0));
    adj[y].push_back(pair<int, int>(x, 1));
    sz[x]++, sz[y]++;
  }
  int ans = 1 << 30;
  for (int i = 1; i <= n; i++) {
    c1 = c2 = 0;
    dfs(i, -1, 0);
    ans = min(ans, c2 - c1);
  }
  printf("%d\n", ans);
  return 0;
}
