#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
const int maxint = 999999999;
struct node {
  int next, id, dir;
  node(int a, int b, int c) {
    next = a;
    id = b;
    dir = c;
  }
};
vector<node> v[maxn];
int x[maxn], y[maxn];
int down[maxn], up[maxn];
bool visit[maxn];
int del;
int n;
void dfs1(int u, int father) {
  visit[u] = true;
  for (int i = 0; i < (int)v[u].size(); i++) {
    int x = v[u][i].next, id = v[u][i].id, dir = v[u][i].dir;
    if (x != father && id != del) {
      dfs1(x, u);
      down[u] += down[x] + dir;
    }
  }
}
void dfs2(int u, int father) {
  for (int i = 0; i < (int)v[u].size(); i++) {
    int x = v[u][i].next, id = v[u][i].id, dir = v[u][i].dir;
    if (x != father && id != del) {
      int brother = down[u] - down[x] - dir;
      if (dir == 0) {
        up[x] = 1 + brother + up[u];
      } else {
        up[x] = 0 + brother + up[u];
      }
      dfs2(x, u);
    }
  }
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) v[i].clear();
    for (int i = 1; i <= n - 1; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      v[a].push_back(node(b, i, 0));
      v[b].push_back(node(a, i, 1));
      x[i] = a;
      y[i] = b;
    }
    del = 0;
    memset(down, 0, sizeof(down));
    memset(up, 0, sizeof(up));
    dfs1(1, -1);
    dfs2(1, -1);
    int ans = maxint;
    for (int i = 1; i <= n; i++) ans = min(ans, up[i] + down[i]);
    for (int i = 1; i <= n - 1; i++) {
      del = i;
      memset(visit, false, sizeof(visit));
      memset(down, 0, sizeof(down));
      memset(up, 0, sizeof(up));
      dfs1(x[i], -1);
      dfs2(x[i], -1);
      int ans1 = maxint;
      for (int j = 1; j <= n; j++)
        if (visit[j]) ans1 = min(ans1, up[j] + down[j]);
      memset(visit, false, sizeof(visit));
      memset(down, 0, sizeof(down));
      memset(up, 0, sizeof(up));
      dfs1(y[i], -1);
      dfs2(y[i], -1);
      int ans2 = maxint;
      for (int j = 1; j <= n; j++)
        if (visit[j]) ans2 = min(ans2, up[j] + down[j]);
      ans = min(ans, ans1 + ans2);
    }
    printf("%d\n", ans);
  }
  return 0;
}
