#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int INF = 1e9 + 10;
const long long LINF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100;
const int MN = 3e3 + 10;
int n;
vector<pair<int, int> > edges[MN];
int ans;
int dp1[MN], dp2[MN];
int sz[MN];
void input() {
  n = in();
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    a = in(), b = in();
    edges[a].push_back(pair<int, int>(b, 1));
    edges[b].push_back(pair<int, int>(a, 0));
  }
}
void dfs1(int s, int pr) {
  for (int i = 0; i < ((int)(edges[s]).size()); ++i) {
    if (edges[s][i].first == pr) continue;
    if (edges[s][i].second == 0) ++sz[s];
    dfs1(edges[s][i].first, s);
    sz[s] += sz[edges[s][i].first];
  }
}
void dfs2(int s, int pr) {
  for (int i = 0; i < ((int)(edges[s]).size()); ++i) {
    if (edges[s][i].first == pr) continue;
    dfs2(edges[s][i].first, s);
  }
  int Mn = sz[s];
  for (int i = 0; i < ((int)(edges[s]).size()); ++i) {
    if (edges[s][i].first == pr) continue;
    if (edges[s][i].second) {
      Mn = min(Mn, dp1[edges[s][i].first] + 1 + sz[s] - sz[edges[s][i].first]);
    } else {
      Mn = min(Mn, dp1[edges[s][i].first] + sz[s] - 1 - sz[edges[s][i].first]);
    }
  }
  dp1[s] = Mn;
  Mn = INF;
  for (int i = 0; i < ((int)(edges[s]).size()); ++i) {
    if (edges[s][i].first == pr) continue;
    if (edges[s][i].second) {
      Mn = min(Mn, dp2[edges[s][i].first] + sz[s] - sz[edges[s][i].first]);
    } else {
      Mn = min(Mn, dp1[edges[s][i].first] + sz[s] - sz[edges[s][i].first] - 1);
      Mn = min(Mn, dp2[edges[s][i].first] + sz[s] - sz[edges[s][i].first]);
    }
  }
  dp2[s] = Mn;
}
int main() {
  input();
  int mn = INF;
  for (int i = 0; i < n; ++i) {
    memset(dp1, 0, sizeof dp1);
    memset(dp2, 0, sizeof dp2);
    memset(sz, 0, sizeof sz);
    dfs1(i, -1);
    dfs2(i, -1);
    mn = min(mn, dp2[i]);
  }
  if (n <= 2) mn = 0;
  cout << mn << '\n';
  return 0;
}
