#include <bits/stdc++.h>
using namespace std;
int lgn = 13;
vector<int> sub(3001);
vector<int> wrong(3001);
vector<int> all(3001);
vector<int> parent(3001);
vector<bool> vis(3001);
vector<int> depth(3001);
int lca[3001][20];
vector<int> tree[3001];
vector<int> dir[3001];
vector<int> fix[3001];
int path[3001][3001];
int dfs(int x) {
  sub[x] = 0;
  lca[x][0] = parent[x];
  for (int i = 1; i < lgn; i++) {
    lca[x][i] = lca[lca[x][i - 1]][i - 1];
  }
  for (int i = 0; i < tree[x].size(); i++) {
    int j = tree[x][i];
    if (vis[j]) continue;
    parent[j] = x;
    if (dir[x][i] == -1) {
      wrong[j] = wrong[x] + 1;
      sub[x]++;
    } else
      wrong[j] = wrong[x];
    depth[j] = depth[x] + 1;
    vis[j] = 1;
    sub[x] += dfs(j);
  }
  return sub[x];
}
int find(int x, int h) {
  if (h == 0) return x;
  if (h == 1) return parent[x];
  int lst = 0;
  for (int i = 0; i < lgn; i++) {
    int tmp = (1 << i);
    if ((h & tmp) > 0) {
      lst = i;
      break;
    }
  }
  int y = lca[x][lst];
  return find(y, h - (1 << lst));
}
int lcs(int x, int y) {
  if (depth[x] > depth[y])
    x = find(x, depth[x] - depth[y]);
  else if (depth[y] > depth[x])
    y = find(y, depth[y] - depth[x]);
  if (x == y) return x;
  if (parent[x] == parent[y]) return parent[x];
  int lst = 0;
  for (int i = 1; i < lgn; i++) {
    if (lca[x][i] == lca[y][i]) {
      lst = i - 1;
      break;
    }
  }
  return lcs(lca[x][lst], lca[y][lst]);
}
void fill(int x) {
  for (int i = 0; i < tree[x].size(); i++) {
    int j = tree[x][i];
    if (j == parent[x]) {
      fix[x][i] = sub[x];
      continue;
    }
    fix[x][i] = sub[1] - sub[j] - wrong[x] + (depth[x] - wrong[x]);
    fill(j);
  }
  all[x] = sub[1] - wrong[x] + (depth[x] - wrong[x]);
}
void fill_paths(int x) {
  for (int i = 0; i < tree[x].size(); i++) {
    int j = tree[x][i];
    if (j == parent[x]) continue;
    path[x][j] = 0;
  }
  int p = parent[x];
  while (p >= 1) {
    for (int i = 0; i < tree[x].size(); i++) {
      int j = tree[x][i];
      if (j == parent[x]) continue;
      path[p][j] = wrong[j] - wrong[p];
      int c = 0;
      if (dir[x][i] == 1) c = 1;
      path[p][j] = min(path[p][j], c + path[p][x]);
    }
    p = parent[p];
  }
  for (int i = 0; i < tree[x].size(); i++) {
    int j = tree[x][i];
    if (j == parent[x]) continue;
    fill_paths(j);
  }
}
int prs(int x, int y) {
  int l = lcs(x, y);
  int tmp = all[l] - (wrong[x] - wrong[l]) - (wrong[y] - wrong[l]);
  if (l == x) {
    tmp = tmp + path[x][y];
    return tmp;
  }
  if (l == y) {
    tmp = tmp + path[y][x];
    return tmp;
  }
  int tmp1 = tmp + path[l][x] + depth[y] - depth[l] - (wrong[y] - wrong[l]);
  int tmp2 = tmp + path[l][y] + depth[x] - depth[l] - (wrong[x] - wrong[l]);
  tmp = min(tmp1, tmp2);
  return tmp;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    tree[x].push_back(y);
    dir[x].push_back(1);
    tree[y].push_back(x);
    dir[y].push_back(-1);
    fix[x].push_back(0);
    fix[y].push_back(0);
  }
  wrong[1] = 0;
  vis[1] = 1;
  parent[1] = 0;
  dfs(1);
  fill(1);
  fill_paths(1);
  int ans = n + 1;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, all[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      ans = min(ans, prs(i, j));
    }
  }
  cout << ans << endl;
}
