#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
vector<pair<int, int> > adj[N];
int a, b, n, rt = 1e9;
void DFS(int u, int p, int t) {
  a = max(a, t);
  for (pair<int, int> x : adj[u])
    if (x.first ^ p) {
      b += x.second;
      DFS(x.first, u, max(0, t + (x.second ? 1 : -1)));
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int aa, bb;
    scanf("%d %d", &aa, &bb);
    adj[aa].push_back({bb, 0});
    adj[bb].push_back({aa, 1});
  }
  for (int i = 1; i <= n; i++) {
    a = b = 0;
    DFS(i, 0, 0);
    rt = min(rt, b - a);
  }
  printf("%d", rt);
}
