#include <bits/stdc++.h>
using namespace std;
const int INF = ((long long)1E9 + 7);
template <class C>
void mini(C& a, C b) {
  a = min(a, b);
}
template <class C>
void maxi(C& a, C b) {
  a = max(a, b);
}
struct node {
  vector<int> out;
  vector<int> in;
  int val;
};
const int MAXN = 3000;
node T[MAXN];
int doit(int v, int p) {
  T[v].val = 0;
  for (__typeof((T[v].out).begin()) it = ((T[v].out).begin());
       it != (T[v].out).end(); ++it) {
    if (*it == p) continue;
    T[v].val += 1 + doit(*it, v);
  }
  for (__typeof((T[v].in).begin()) it = ((T[v].in).begin());
       it != (T[v].in).end(); ++it) {
    if (*it == p) continue;
    T[v].val += doit(*it, v);
  }
  return T[v].val;
}
int compute(int v, int p, int best) {
  int ans = best;
  for (__typeof((T[v].out).begin()) it = ((T[v].out).begin());
       it != (T[v].out).end(); ++it) {
    if (*it == p) continue;
    maxi(ans, compute(*it, v, best + 1));
  }
  for (__typeof((T[v].in).begin()) it = ((T[v].in).begin());
       it != (T[v].in).end(); ++it) {
    if (*it == p) continue;
    maxi(ans, compute(*it, v, max(best - 1, 0)));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    T[b].out.push_back(a);
    T[a].in.push_back(b);
  }
  int mn = n - 1;
  for (int r = 0; r < (n); ++r) {
    doit(r, -1);
    mini(mn, T[r].val - compute(r, -1, 0));
  }
  cout << mn << endl;
  return 0;
}
