#include <bits/stdc++.h>
using namespace std;
int dp[3010][3010];
int dist[3010][3010];
int P[3010];
int dir[3010];
int ord[3010];
int lca[3010][3010];
int depth[3010];
bool vis[3010];
int away[3010];
int K;
vector<int> E[3010];
vector<int> rev[3010];
int better(int i, int j) {
  if (depth[i] > depth[j]) return i;
  return j;
}
void dfs(int i) {
  if (vis[i]) return;
  vis[i] = true;
  int numE = E[i].size();
  for (int x = (0); x <= (((numE)-1)); ++x) {
    int j = E[i][x];
    if (vis[j]) continue;
    P[j] = i;
    depth[j] = depth[i] + 1;
    dir[j] = 1;
    dfs(j);
  }
  int numrev = rev[i].size();
  for (int y = (0); y <= (((numrev)-1)); ++y) {
    int j = rev[i][y];
    if (vis[j]) continue;
    depth[j] = depth[i] + 1;
    P[j] = i;
    dir[j] = 0;
    dfs(j);
  }
  K++;
  ord[K] = i;
}
int asearch(int i) {
  if (vis[i]) return 0;
  vis[i] = true;
  int ans = 0;
  int numE = E[i].size();
  for (int x = (0); x <= (((numE)-1)); ++x) {
    int j = E[i][x];
    if (vis[j]) continue;
    ans += asearch(j);
  }
  int numrev = rev[i].size();
  for (int y = (0); y <= (((numrev)-1)); ++y) {
    int j = rev[i][y];
    if (vis[j]) continue;
    ans += asearch(j) + 1;
  }
  return ans;
}
int da[3010];
int ub[3010];
int f[3010][3010];
int main() {
  int N;
  cin >> N;
  int i, j;
  for (int k = (0); k <= (((N - 1) - 1)); ++k) {
    cin >> i >> j;
    E[i].push_back(j);
    rev[j].push_back(i);
  }
  memset(vis, 0, sizeof(vis));
  K = 0;
  depth[0] = 0;
  depth[1] = 1;
  dfs(1);
  for (int pp = (N); pp >= (1); --pp) {
    int i = ord[pp];
    for (int qq = (N); qq >= (1); --qq) {
      int j = ord[qq];
      if (j == i)
        lca[i][j] = j;
      else if (j == P[i])
        lca[i][j] = j;
      else if (i == P[j])
        lca[i][j] = i;
      else
        lca[i][j] = better(lca[P[i]][j], lca[i][P[j]]);
      lca[j][i] = lca[i][j];
    }
  }
  for (int i = (1); i <= (N); ++i)
    for (int j = (1); j <= (N); ++j)
      dist[i][j] =
          (depth[i] - depth[lca[i][j]]) + (depth[j] - depth[lca[i][j]]);
  for (int pp = (1); pp <= (N); ++pp) {
    int i = ord[pp];
    int numE = E[i].size();
    ub[i] = 0;
    for (int x = (0); x <= (((numE)-1)); ++x) {
      int j = E[i][x];
      if (j == P[i]) continue;
      ub[i] += ub[j];
    }
    int numrev = rev[i].size();
    for (int x = (0); x <= (((numrev)-1)); ++x) {
      int j = rev[i][x];
      if (j == P[i]) continue;
      ub[i] += ub[j] + 1;
    }
  }
  for (int pp = (N); pp >= (1); --pp) {
    int i = ord[pp];
    da[i] += da[P[i]];
    if (dir[i] == 1) da[i]++;
  }
  for (int pp = (N); pp >= (1); --pp) {
    int i = ord[pp];
    for (int qq = (N); qq >= (1); --qq) {
      int j = ord[qq];
      int k = lca[i][j];
      if (k == i || k == j) {
        int h = i + j - k;
        int ans1 = f[P[h]][k] + (dir[h] == 1);
        int ans2 = dist[h][k] - (da[h] - da[k]);
        f[i][j] = min(ans1, ans2);
      } else {
        int ans1 = (dir[i] == 1) + f[P[i]][j];
        int ans2 = (dir[j] == 1) + f[i][P[j]];
        f[i][j] = min(ans1, ans2);
      }
      f[j][i] = max(f[j][i], f[i][j]);
    }
  }
  for (int i = (1); i <= (N); ++i) {
    memset(vis, 0, sizeof(vis));
    away[i] = asearch(i);
  }
  int ans = 100000;
  for (int i = (1); i <= (N); ++i) {
    for (int j = (1); j <= (N); ++j) {
      assert(!((away[i] + away[j] - dist[i][j]) % 2));
      int num = (away[i] + away[j] - dist[i][j]) / 2 + f[i][j];
      ans = min(ans, num);
    }
  }
  cout << ans << endl;
}
