#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int Data;
  bool Flag;
};
const int inf = 1000000000;
vector<Edge> G[3000];
int Degree[3000], Parent[3000], Next[3000], First[3000];
bool Flag[3000];
bool Visited[3000][3000][3];
int F[3000][3000][3];
void DFS(int V) {
  int Last = -1;
  for (int i = 0; i < G[V].size(); i++) {
    int U = G[V][i].Data;
    if (U == Parent[V]) continue;
    Flag[U] = G[V][i].Flag;
    Parent[U] = V;
    if (Last == -1)
      First[V] = U;
    else
      Next[Last] = U;
    Last = U;
    DFS(U);
  }
}
int DP(int V, int D, int Rest) {
  if (V == -1) return (D || Rest) ? 0 : inf;
  if (Visited[V][D][Rest]) return F[V][D][Rest];
  Visited[V][D][Rest] = true;
  F[V][D][Rest] = inf;
  int Delta = Flag[V] ? 1 : -1;
  for (int i = 0; i <= Rest; i++) {
    int X = DP(First[V], Degree[V], i) + DP(Next[V], D, Rest - i);
    F[V][D][Rest] = min(F[V][D][Rest], X);
    int Y = DP(First[V], Degree[V] - Delta, i) +
            DP(Next[V], D + Delta, Rest - i) + 1;
    F[V][D][Rest] = min(F[V][D][Rest], Y);
  }
  return F[V][D][Rest];
}
int main() {
  int N;
  scanf("%d", &N);
  memset(Degree, 0, sizeof(Degree));
  for (int i = 1; i < N; i++) {
    int X, Y;
    scanf("%d%d", &X, &Y);
    X--;
    Y--;
    Degree[Y]++;
    G[X].push_back((Edge){Y, true});
    G[Y].push_back((Edge){X, false});
  }
  Parent[0] = -1;
  memset(Next, -1, sizeof(Next));
  memset(First, -1, sizeof(First));
  DFS(0);
  printf("%d\n", DP(First[0], Degree[0], 2));
  return 0;
}
