#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int x, y, dir;
} edge[6010];
int p;
int cnt[3005];
int mx = -10000000;
int ans = 100000000;
vector<pair<int, int> > v[3005];
void dfs(int pre, int x, int val) {
  cnt[x] = 0;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i].first != pre) {
      if (edge[v[x][i].second].dir == 1)
        dfs(x, v[x][i].first, 1 + val);
      else
        dfs(x, v[x][i].first, val - 1);
      cnt[x] += cnt[v[x][i].first] + edge[v[x][i].second].dir;
    }
  }
  mx = max(mx, val);
}
int main() {
  scanf("%d", &n);
  if (n == 1) {
    puts("0");
    return 0;
  }
  for (int i = 1; i < n; i++) {
    int tx, ty;
    scanf("%d%d", &tx, &ty);
    v[tx].push_back(make_pair(ty, p));
    edge[p].x = tx;
    edge[p].y = ty;
    edge[p++].dir = 0;
    v[ty].push_back(make_pair(tx, p));
    edge[p].x = ty;
    edge[p].y = tx;
    edge[p++].dir = 1;
  }
  for (int i = 0; i < p; i += 2) {
    int tx = edge[i].x, ty = edge[i].y;
    mx = -1000000;
    dfs(tx, ty, 0);
    int now = cnt[ty] - mx;
    mx = -100000;
    dfs(ty, tx, 0);
    now += cnt[tx] - mx;
    ans = min(ans, now);
  }
  printf("%d\n", ans);
  return 0;
}
