#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v;
  bool p;
};
int n, used[200002], red, RedOnPath[200002], l = 1;
vector<edge> v[200002];
void read() {
  scanf("%d", &n);
  int i, a, b;
  for (i = 0; i < n - 1; i++) {
    edge t;
    scanf("%d%d", &a, &b);
    t.v = b;
    t.p = 0;
    v[a].push_back(t);
    t.v = a;
    t.p = 1;
    v[b].push_back(t);
  }
}
int bans, bans2;
void dfs(int i) {
  used[i] = l;
  int j, sz = v[i].size();
  for (j = 0; j < sz; j++)
    if (used[v[i][j].v] == 0) {
      if (v[i][j].p) {
        red++;
        RedOnPath[v[i][j].v] = RedOnPath[i] + 1;
      } else
        RedOnPath[v[i][j].v] = max(0, RedOnPath[i] - 1);
      if (RedOnPath[v[i][j].v] > bans) {
        bans = RedOnPath[v[i][j].v];
      }
      l++;
      dfs(v[i][j].v);
      l--;
    }
}
void solve() {
  int ans = -1;
  int i;
  for (i = 1; i <= n; i++) {
    memset(used, 0, sizeof(used));
    memset(RedOnPath, 0, sizeof(RedOnPath));
    l = 1;
    red = 0;
    bans = 0;
    ;
    dfs(i);
    int tans = red - bans;
    if (tans < ans || ans == -1) ans = tans;
  }
  printf("%d\n", max(0, ans));
}
int main() {
  read();
  solve();
  return 0;
}
